This commit is contained in:
modmuss50 2015-10-22 18:19:05 +01:00
parent e34436a94d
commit 50fa2e8a1d
12 changed files with 134 additions and 50 deletions

View file

@ -0,0 +1,9 @@
package techreborn.api;
import java.util.List;
public interface IListInfoProvider {
void addInfo(List<String> info, boolean isRealTile);
}

View file

@ -0,0 +1,28 @@
package techreborn.client;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.client.Minecraft;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
import techreborn.api.IListInfoProvider;
public class StackToolTipEvent {
@SubscribeEvent
public void handleItemTooltipEvent(ItemTooltipEvent event) {
if(event.itemStack.getItem() instanceof IListInfoProvider){
((IListInfoProvider) event.itemStack.getItem()).addInfo(event.toolTip, false);
} else{
Block block = Block.getBlockFromItem(event.itemStack.getItem());
if(block != null && block instanceof BlockContainer){
TileEntity tile = block.createTileEntity(Minecraft.getMinecraft().theWorld, event.itemStack.getItemDamage());
if(tile instanceof IListInfoProvider){
((IListInfoProvider) tile).addInfo(event.toolTip, false);
}
}
}
}
}

View file

@ -8,6 +8,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import techreborn.api.IListInfoProvider;
import techreborn.tiles.TileMachineBase;
import java.util.ArrayList;
@ -23,7 +24,9 @@ public class WailaProviderMachines implements IWailaDataProvider {
TileMachineBase machine = (TileMachineBase) accessor.getTileEntity();
machine.addWailaInfo(info);
if(accessor.getTileEntity() instanceof IListInfoProvider){
((IListInfoProvider) accessor.getTileEntity()).addInfo(info, true);
}
tip.addAll(info);
info.clear();

View file

@ -1,5 +1,7 @@
package techreborn.items;
import ic2.api.reactor.IReactor;
import ic2.api.reactor.IReactorComponent;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
@ -15,7 +17,7 @@ import techreborn.init.ModItems;
import java.security.InvalidParameterException;
import java.util.List;
public class ItemParts extends Item {
public class ItemParts extends Item implements IReactorComponent {
public static ItemStack getPartByName(String name, int count) {
for (int i = 0; i < types.length; i++) {
if (types[i].equalsIgnoreCase(name)) {
@ -97,4 +99,40 @@ public class ItemParts extends Item {
}
return itemStack;
}
@Override
public void processChamber(IReactor iReactor, ItemStack itemStack, int i, int i1, boolean b) {
}
@Override
public boolean acceptUraniumPulse(IReactor iReactor, ItemStack itemStack, ItemStack itemStack1, int i, int i1, int i2, int i3, boolean b) {
return false;
}
@Override
public boolean canStoreHeat(IReactor iReactor, ItemStack itemStack, int i, int i1) {
return false;
}
@Override
public int getMaxHeat(IReactor iReactor, ItemStack itemStack, int i, int i1) {
return 0;
}
@Override
public int getCurrentHeat(IReactor iReactor, ItemStack itemStack, int i, int i1) {
return 0;
}
@Override
public int alterHeat(IReactor iReactor, ItemStack itemStack, int i, int i1, int i2) {
return 0;
}
@Override
public float influenceExplosion(IReactor iReactor, ItemStack itemStack) {
return 0;
}
}

View file

@ -15,6 +15,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.ForgeDirection;
import techreborn.api.IListInfoProvider;
import techreborn.api.power.IEnergyInterfaceTile;
import techreborn.asm.Strippable;
import techreborn.config.ConfigTechReborn;
@ -29,7 +30,7 @@ import java.util.List;
})
public abstract class TilePowerAcceptor extends RFProviderTile implements
IEnergyReceiver, IEnergyProvider, //Cofh
IEnergyInterfaceTile, //TechReborn
IEnergyInterfaceTile, IListInfoProvider, //TechReborn
IEnergyTile, IEnergySink, IEnergySource, //Ic2
IEnergySourceInfo //IC2 Classic
{
@ -287,8 +288,7 @@ public abstract class TilePowerAcceptor extends RFProviderTile implements
}
@Override
public void addWailaInfo(List<String> info) {
super.addWailaInfo(info);
public void addInfo(List<String> info, boolean isRealTile) {
info.add("Energy buffer Size " + getEUString(getMaxPower()));
info.add("Max Input " + getEUString(getMaxInput()));
info.add("Max Output " + getEUString(getMaxOutput()));
@ -317,4 +317,6 @@ public abstract class TilePowerAcceptor extends RFProviderTile implements
public int getMaxEnergyAmount() {
return (int) getMaxOutput();
}
}

View file

@ -4,6 +4,7 @@ import cpw.mods.fml.client.registry.ClientRegistry;
import net.minecraft.init.Blocks;
import net.minecraftforge.common.MinecraftForge;
import techreborn.client.IconSupplier;
import techreborn.client.StackToolTipEvent;
import techreborn.client.VersionCheckerClient;
import techreborn.client.hud.ChargeHud;
import techreborn.client.keybindings.KeyBindings;
@ -21,6 +22,7 @@ public class ClientProxy extends CommonProxy {
MinecraftForge.EVENT_BUS.register(new IconSupplier());
MinecraftForge.EVENT_BUS.register(new ChargeHud());
MinecraftForge.EVENT_BUS.register(new VersionCheckerClient());
MinecraftForge.EVENT_BUS.register(new StackToolTipEvent());
multiblockRenderEvent = new MultiblockRenderEvent();
MinecraftForge.EVENT_BUS.register(multiblockRenderEvent);
ClientRegistry.registerKeyBinding(KeyBindings.config);

View file

@ -8,6 +8,7 @@ import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import techreborn.api.IListInfoProvider;
import techreborn.api.recipe.RecipeCrafter;
import techreborn.config.ConfigTechReborn;
import techreborn.init.ModBlocks;
@ -17,7 +18,7 @@ import techreborn.util.Inventory;
import java.util.List;
public class TileCentrifuge extends TilePowerAcceptor implements IWrenchable, IEnergyTile, IInventory, ISidedInventory {
public class TileCentrifuge extends TilePowerAcceptor implements IWrenchable, IEnergyTile, IInventory, ISidedInventory, IListInfoProvider {
public int tickTime;
public Inventory inventory = new Inventory(11, "TileCentrifuge", 64);
@ -97,8 +98,7 @@ public class TileCentrifuge extends TilePowerAcceptor implements IWrenchable, IE
}
@Override
public void addWailaInfo(List<String> info) {
super.addWailaInfo(info);
public void addInfo(List<String> info, boolean isRealTile) {
// info.add("Power Stored " + energy.getEnergyStored() +" EU");
// if(crafter.currentRecipe !=null){
// info.add("Power Usage " + crafter.currentRecipe.euPerTick() + " EU/t");

View file

@ -8,6 +8,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import techreborn.api.IListInfoProvider;
import techreborn.init.ModBlocks;
import techreborn.util.Inventory;
import techreborn.util.ItemUtils;
@ -15,7 +16,7 @@ import techreborn.util.ItemUtils;
import java.util.List;
public class TileDigitalChest extends TileMachineBase implements IInventory,
IWrenchable {
IWrenchable, IListInfoProvider {
// Slot 0 = Input
// Slot 1 = Output
@ -230,8 +231,7 @@ public class TileDigitalChest extends TileMachineBase implements IInventory,
}
@Override
public void addWailaInfo(List<String> info) {
super.addWailaInfo(info);
public void addInfo(List<String> info, boolean isRealTile) {
int size = 0;
String name = "of nothing";
if (storedItem != null) {
@ -245,4 +245,5 @@ public class TileDigitalChest extends TileMachineBase implements IInventory,
info.add(size + " " + name);
}
}

View file

@ -10,6 +10,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.*;
import techreborn.api.IListInfoProvider;
import techreborn.api.recipe.RecipeCrafter;
import techreborn.blocks.BlockMachineCasing;
import techreborn.init.ModBlocks;
@ -22,7 +23,7 @@ import techreborn.util.Tank;
import java.util.List;
public class TileIndustrialSawmill extends TilePowerAcceptor implements IWrenchable, IEnergyTile, IFluidHandler, IInventory, ISidedInventory {
public class TileIndustrialSawmill extends TilePowerAcceptor implements IWrenchable, IEnergyTile, IFluidHandler, IInventory, ISidedInventory, IListInfoProvider {
public int tickTime;
public Inventory inventory = new Inventory(5, "TileIndustrialSawmill", 64);
@ -124,11 +125,13 @@ public class TileIndustrialSawmill extends TilePowerAcceptor implements IWrencha
}
@Override
public void addWailaInfo(List<String> info) {
super.addWailaInfo(info);
info.add("Power Stored " + getEnergy() + " EU");
if (crafter.currentRecipe != null) {
info.add("Power Usage " + crafter.currentRecipe.euPerTick() + " EU/t");
public void addInfo(List<String> info, boolean isRealTile) {
super.addInfo(info, isRealTile);
if(isRealTile){
info.add("Power Stored " + getEnergy() + " EU");
if (crafter.currentRecipe != null) {
info.add("Power Usage " + crafter.currentRecipe.euPerTick() + " EU/t");
}
}
}

View file

@ -1,7 +1,5 @@
package techreborn.tiles;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
@ -9,8 +7,6 @@ import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import techreborn.packets.PacketHandler;
import java.util.List;
public abstract class TileMachineBase extends TileEntity {
int rotation;
@ -22,11 +18,6 @@ public abstract class TileMachineBase extends TileEntity {
}
}
@SideOnly(Side.CLIENT)
public void addWailaInfo(List<String> info) {
}
public Packet getDescriptionPacket() {
NBTTagCompound nbtTag = new NBTTagCompound();
writeToNBT(nbtTag);

View file

@ -9,6 +9,7 @@ import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import powercrystals.minefactoryreloaded.api.IDeepStorageUnit;
import techreborn.api.IListInfoProvider;
import techreborn.init.ModBlocks;
import techreborn.util.Inventory;
import techreborn.util.ItemUtils;
@ -16,7 +17,7 @@ import techreborn.util.ItemUtils;
import java.util.List;
public class TileQuantumChest extends TileMachineBase implements IInventory,
IWrenchable, IDeepStorageUnit {
IWrenchable, IDeepStorageUnit, IListInfoProvider {
// Slot 0 = Input
// Slot 1 = Output
@ -230,22 +231,7 @@ public class TileQuantumChest extends TileMachineBase implements IInventory,
return dropStack;
}
@Override
public void addWailaInfo(List<String> info) {
super.addWailaInfo(info);
int size = 0;
String name = "of nothing";
if (storedItem != null) {
name = storedItem.getDisplayName();
size += storedItem.stackSize;
}
if (getStackInSlot(1) != null) {
name = getStackInSlot(1).getDisplayName();
size += getStackInSlot(1).stackSize;
}
info.add(size + " " + name);
}
@Override
public ItemStack getStoredItemType() {
@ -270,4 +256,21 @@ public class TileQuantumChest extends TileMachineBase implements IInventory,
public int getMaxStoredCount() {
return this.storage;
}
@Override
public void addInfo(List<String> info, boolean isRealTile) {
if(isRealTile){
int size = 0;
String name = "of nothing";
if (storedItem != null) {
name = storedItem.getDisplayName();
size += storedItem.stackSize;
}
if (getStackInSlot(1) != null) {
name = getStackInSlot(1).getDisplayName();
size += getStackInSlot(1).stackSize;
}
info.add(size + " " + name);
}
}
}

View file

@ -13,6 +13,7 @@ import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
import techreborn.api.IListInfoProvider;
import techreborn.init.ModBlocks;
import techreborn.util.FluidUtils;
import techreborn.util.Inventory;
@ -21,7 +22,7 @@ import techreborn.util.Tank;
import java.util.List;
public class TileQuantumTank extends TileMachineBase implements IFluidHandler,
IInventory, IWrenchable {
IInventory, IWrenchable, IListInfoProvider {
public Tank tank = new Tank("TileQuantumTank", Integer.MAX_VALUE, this);
public Inventory inventory = new Inventory(3, "TileQuantumTank", 64);
@ -217,13 +218,16 @@ public class TileQuantumTank extends TileMachineBase implements IFluidHandler,
}
@Override
public void addWailaInfo(List<String> info) {
super.addWailaInfo(info);
if (tank.getFluid() != null) {
info.add(tank.getFluidAmount() + " of "
+ tank.getFluidType().getName());
} else {
info.add("Empty");
public void addInfo(List<String> info, boolean isRealTile) {
if(isRealTile){
if (tank.getFluid() != null) {
info.add(tank.getFluidAmount() + " of "
+ tank.getFluidType().getName());
} else {
info.add("Empty");
}
}
info.add("Capacity " + tank.getCapacity() + " mb");
}
}