From 05c78126859231a68e199dc34613689bd0978e2f Mon Sep 17 00:00:00 2001 From: Foghrye4 Date: Mon, 11 Apr 2016 19:44:54 +0300 Subject: Initial commit --- ihl/worldgen/ores/DebugScannerTileEntity.java | 161 ++++++++++++++++++++++++++ 1 file changed, 161 insertions(+) create mode 100644 ihl/worldgen/ores/DebugScannerTileEntity.java (limited to 'ihl/worldgen/ores/DebugScannerTileEntity.java') diff --git a/ihl/worldgen/ores/DebugScannerTileEntity.java b/ihl/worldgen/ores/DebugScannerTileEntity.java new file mode 100644 index 0000000..2102cf0 --- /dev/null +++ b/ihl/worldgen/ores/DebugScannerTileEntity.java @@ -0,0 +1,161 @@ +package ihl.worldgen.ores; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.IFluidContainerItem; +import net.minecraftforge.oredict.OreDictionary; +import ic2.core.ContainerBase; +import ic2.core.IC2; +import ic2.core.IHasGui; +import ic2.core.block.TileEntityInventory; +import ic2.core.block.invslot.InvSlot; + +public class DebugScannerTileEntity extends TileEntityInventory implements IHasGui +{ + public final InvSlot itemsSlot; + private ItemStack lastItem; + public List oreDictionaryEntries = new ArrayList(); + + public DebugScannerTileEntity() + { + this.itemsSlot = new InvSlot(this, "drainInput", 0, InvSlot.Access.I, 2); + } + + @Override + public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) { + return this.getFacing()!=(short)side && side!=0 && side!=1; + } + + @Override + public void updateEntityClient() + { + if(IC2.platform.isRendering()) + { + if(this.itemsSlot.get(0)!=null && this.itemsSlot.get(0)!=lastItem) + { + this.oreDictionaryEntries.clear(); + int[] ids = OreDictionary.getOreIDs(this.itemsSlot.get()); + String itemNameFromIR = Item.itemRegistry.getNameForObject(this.itemsSlot.get().getItem()); + this.oreDictionaryEntries.add("ItemRegistry entry:"); + this.oreDictionaryEntries.add(" "+itemNameFromIR); + this.oreDictionaryEntries.add("Item damage: " + this.itemsSlot.get().getItemDamage()); + this.oreDictionaryEntries.add("Item class:"); + this.oreDictionaryEntries.add(" "+this.itemsSlot.get().getItem().getClass().getCanonicalName()); + if(this.itemsSlot.get().stackTagCompound!=null) + { + this.oreDictionaryEntries.add("NBT keys:"); + Iterator iterator = this.itemsSlot.get().stackTagCompound.func_150296_c().iterator(); + while(iterator.hasNext()) + { + String entry = (String) iterator.next(); + if(this.itemsSlot.get().stackTagCompound.getTag(entry) instanceof NBTTagCompound) + { + this.oreDictionaryEntries.add(" "+entry); + NBTTagCompound ct = this.itemsSlot.get().stackTagCompound.getCompoundTag(entry); + if(ct!=null && ct.func_150296_c()!=null && !ct.func_150296_c().isEmpty()) + { + this.oreDictionaryEntries.add(" -NBT compound tag subkeys:"); + Iterator stIterator = ct.func_150296_c().iterator(); + while(stIterator.hasNext()) + { + String entry2 = (String) stIterator.next(); + this.oreDictionaryEntries.add(" "+entry2+"="+ct.getString(entry2)); + } + } + } + else + { + this.oreDictionaryEntries.add(" "+entry+"="+this.itemsSlot.get().stackTagCompound.getString(entry)); + } + } + } + if(ids.length>0) + { + this.oreDictionaryEntries.add("Ore dict. entries:"); + for(int i=0;i "); + } + this.oreDictionaryEntries.add("Fluid flowing icon:"); + if(fluid.getFluid().getFlowingIcon()!=null) + { + this.oreDictionaryEntries.add(" "+fluid.getFluid().getFlowingIcon().getIconName()); + } + else + { + this.oreDictionaryEntries.add(" "); + } + } + } + lastItem=this.itemsSlot.get(1); + } + } + } + + /** + * Returns the name of the inventory + */ + @Override + public String getInventoryName() + { + return "debugScanner"; + } + + @Override + public ContainerBase getGuiContainer(EntityPlayer entityPlayer) + { + return new DebugScannerContainer(entityPlayer, this); + } + + @Override + @SideOnly(Side.CLIENT) + public GuiScreen getGui(EntityPlayer entityPlayer, boolean isAdmin) + { + return new DebugScannerGui(new DebugScannerContainer(entityPlayer, this)); + } + + @Override + public void onGuiClosed(EntityPlayer entityPlayer) {} + + + public boolean getGui(EntityPlayer player) + { + return this instanceof IHasGui ? (IC2.platform.isSimulating() ? IC2.platform.launchGui(player, this) : true) : false; + } + } \ No newline at end of file -- cgit v1.2.3