Add more tooltip help and cell handler for void cell

This commit is contained in:
Firenoo authored and Martin Robertz committed 2023-05-01 19:04:39 +02:00
1 parent 61ada60c92
commit 1fd5b9da51
4 files changed
+74 -8

No files matched your search

@@ -4,11 +4,9 @@ import appeng.api.AEApi;
import appeng.api.definitions.IItemDefinition;
import com.glodblock.github.common.item.ItemMultiFluidStorageCell;
import com.glodblock.github.crossmod.extracells.parts.*;
import com.glodblock.github.crossmod.extracells.storage.ProxyExtremeStorageCell;
import com.glodblock.github.crossmod.extracells.storage.ProxyFluidStorageCell;
import com.glodblock.github.crossmod.extracells.storage.ProxyItemCellHandler;
import com.glodblock.github.crossmod.extracells.storage.ProxyItemStorageCell;
import com.glodblock.github.crossmod.extracells.storage.*;
import com.glodblock.github.loader.ItemAndBlockHolder;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.item.Item;
import java.util.HashMap;
@@ -50,6 +48,7 @@ public class ItemReplacements {
16384, 131072, 4.0);
// Thanks, AEApi.
AEApi.instance().registries().cell().addCellHandler(new ProxyItemCellHandler());
AEApi.instance().registries().cell().addCellHandler(new ProxyVoidCellHandler());
deprecateItemStorage(0, AEApi.instance().definitions().items().cell256k(), 256, 2048, 2.5);
deprecateItemStorage(1, AEApi.instance().definitions().items().cell1024k(), 1024, 8192, 3.0);
deprecateItemStorage(2, AEApi.instance().definitions().items().cell4096k(), 4096, 32768, 3.5);
@@ -59,7 +58,10 @@ public class ItemReplacements {
AEApi.instance().definitions().items().cellQuantum(), Integer.MAX_VALUE / 16, 4096, 1000.0);
deprecateExtremeStorage("storage.physical.advanced.singularity", 0,
AEApi.instance().definitions().items().cellSingularity(), Long.MAX_VALUE / 16, 4096, 15000.0);
deprecateItem("storage.physical.void", 0, AEApi.instance().definitions().items().cellVoid());
//Deprecate void cell manually
ProxyVoidStorageCell voidCell = new ProxyVoidStorageCell();
GameRegistry.registerItem(voidCell, "ec2placeholder.storage.physical.void");
registry.put("extracells:storage.physical.void", voidCell);
deprecateItem("pattern.fluid", ItemAndBlockHolder.PATTERN);
deprecateItem("terminal.fluid.wireless", ItemAndBlockHolder.WIRELESS_FLUID_TERM);
/* Storage casings */
@@ -2,13 +2,14 @@ package com.glodblock.github.crossmod.extracells;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.item.FCBaseItem;
import com.glodblock.github.common.item.ItemMultiFluidStorageCell;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.World;
import java.util.HashMap;
@@ -29,6 +30,7 @@ public class ProxyItem extends FCBaseItem {
public ProxyItem(String ec2itemName) {
this.name = ec2itemName;
this.replacements = new HashMap<>();
setUnlocalizedName("ec2placeholder." + name);
}
@Override
@@ -52,8 +54,15 @@ public class ProxyItem extends FCBaseItem {
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List info, boolean p_77624_4_) {
info.add("§7(Extra Cells Placeholder): " + name);
info.add("§7Put in your inventory to get a replacement (or disappear if incompatible)");
int meta = stack.getItemDamage();
ProxyItemEntry itemRepl = replacements.get(meta);
if (itemRepl != null) {
info.add(EnumChatFormatting.RED + "Extra Cells Placeholder for:");
info.add(EnumChatFormatting.AQUA + itemRepl.replacement.getUnlocalizedName());
info.add(EnumChatFormatting.GOLD + "Put in your inventory to get a replacement.");
info.add(EnumChatFormatting.GOLD + "It will disappear if no replacement was found.");
info.add(EnumChatFormatting.RED + "Report missing conversions on the Github.");
}
}
@Override
@@ -74,6 +83,7 @@ public class ProxyItem extends FCBaseItem {
}
player.inventory.setInventorySlotContents(i, replaceStack);
}
break;
}
}
}
@@ -0,0 +1,11 @@
package com.glodblock.github.crossmod.extracells.storage;
import appeng.core.features.registries.entries.VoidCellHandler;
import net.minecraft.item.ItemStack;
public class ProxyVoidCellHandler extends VoidCellHandler {
@Override
public boolean isCell(ItemStack is) {
return is != null && is.getItem() != null && is.getItem() instanceof ProxyVoidStorageCell;
}
}
@@ -0,0 +1,43 @@
package com.glodblock.github.crossmod.extracells.storage;
import appeng.api.AEApi;
import appeng.core.localization.GuiText;
import appeng.items.storage.ItemVoidStorageCell;
import com.glodblock.github.crossmod.extracells.ProxyItem;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.World;
import java.util.List;
public class ProxyVoidStorageCell extends ItemVoidStorageCell {
private final String name = AEApi.instance().definitions().items().cellVoid().maybeStack(1).get().getUnlocalizedName();
@Override
public void addCheckedInformation(ItemStack stack, EntityPlayer player, List<String> info, boolean displayMoreInfo) {
info.add(EnumChatFormatting.RED + "Extra Cells Placeholder for:");
info.add(EnumChatFormatting.AQUA + name);
info.add(EnumChatFormatting.GOLD + "Put in your inventory to get a replacement.");
info.add(EnumChatFormatting.GOLD + "It will disappear if no replacement was found.");
info.add(EnumChatFormatting.RED + "Report missing conversions on the Github.");
}
@Override
public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int p_77663_4_, boolean p_77663_5_) {
if (!worldIn.isRemote && entityIn instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) entityIn;
for (int i = 0; i < player.inventory.getSizeInventory(); ++i) {
ItemStack s = player.inventory.getStackInSlot(i);
if (s == stack) {
ItemStack replaceStack = AEApi.instance().definitions().items().cellVoid().maybeStack(1).get();
player.inventory.setInventorySlotContents(i, replaceStack);
break;
}
}
}
}
}