ActuallyAdditions/src/main/java/ellpeck/actuallyadditions/waila/WailaDataProvider.java

97 lines
3.4 KiB
Java
Raw Normal View History

2015-04-26 20:07:57 +02:00
package ellpeck.actuallyadditions.waila;
2015-05-20 22:39:43 +02:00
import ellpeck.actuallyadditions.blocks.BlockCompost;
import ellpeck.actuallyadditions.config.values.ConfigBoolValues;
2015-04-26 20:07:57 +02:00
import ellpeck.actuallyadditions.tile.TileEntityCompost;
2015-05-20 22:39:43 +02:00
import ellpeck.actuallyadditions.util.INameableItem;
2015-04-26 20:07:57 +02:00
import ellpeck.actuallyadditions.util.ModUtil;
import ellpeck.actuallyadditions.util.Util;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
import mcp.mobius.waila.api.IWailaRegistrar;
2015-05-20 22:39:43 +02:00
import net.minecraft.block.Block;
import net.minecraft.item.Item;
2015-04-26 20:07:57 +02:00
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
2015-05-20 22:39:43 +02:00
import java.util.ArrayList;
2015-04-26 20:07:57 +02:00
import java.util.List;
@SuppressWarnings("unused")
public class WailaDataProvider implements IWailaDataProvider{
private final String WAILA_PRE_LANG = "gui." + ModUtil.MOD_ID_LOWER + ".waila.";
2015-05-20 22:39:43 +02:00
public static final ArrayList<Block> registerList = new ArrayList<Block>();
2015-04-26 20:07:57 +02:00
@Override
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config){
return null;
}
@Override
2015-05-20 22:39:43 +02:00
public List<String> getWailaHead(ItemStack stack, List<String> currentTip, IWailaDataAccessor accessor, IWailaConfigHandler config){
if(ConfigBoolValues.DO_WAILA_INFO.isEnabled()){
if(accessor.getBlock() instanceof INameableItem){
Item.getItemFromBlock(accessor.getBlock()).addInformation(stack, accessor.getPlayer(), currentTip, true);
}
}
2015-04-26 20:07:57 +02:00
return currentTip;
}
@Override
2015-05-20 22:39:43 +02:00
public List<String> getWailaBody(ItemStack stack, List<String> currentTip, IWailaDataAccessor accessor, IWailaConfigHandler config){
2015-04-26 20:07:57 +02:00
2015-05-20 22:39:43 +02:00
if(accessor.getTileEntity() instanceof TileEntityCompost){
this.compostBody(accessor, currentTip);
}
2015-04-26 20:07:57 +02:00
return currentTip;
}
2015-04-26 21:09:25 +02:00
public void compostBody(IWailaDataAccessor accessor, List<String> currentTip){
int meta = accessor.getMetadata();
TileEntityCompost tile = (TileEntityCompost)accessor.getTileEntity();
2015-04-26 20:07:57 +02:00
if(meta <= tile.amountNeededToConvert){
2015-05-20 22:39:43 +02:00
String tip1 = StatCollector.translateToLocal(WAILA_PRE_LANG + "compostAmount.name") + ": " + meta + "/" + tile.amountNeededToConvert;
currentTip.add(tip1);
if(meta == tile.amountNeededToConvert){
2015-05-20 22:39:43 +02:00
currentTip.add(StatCollector.translateToLocal(WAILA_PRE_LANG + "compostConverting.name"));
2015-04-26 20:07:57 +02:00
}
}
if(meta == tile.amountNeededToConvert+1){
2015-05-20 22:39:43 +02:00
currentTip.add(StatCollector.translateToLocal(WAILA_PRE_LANG + "compostDone.name"));
}
2015-04-26 20:07:57 +02:00
}
@Override
2015-05-20 22:39:43 +02:00
public List<String> getWailaTail(ItemStack stack, List<String> currentTip, IWailaDataAccessor accessor, IWailaConfigHandler config){
2015-04-26 20:07:57 +02:00
return currentTip;
}
2015-04-26 21:09:25 +02:00
@Override
2015-04-26 20:07:57 +02:00
public NBTTagCompound getNBTData(TileEntity te, NBTTagCompound tag, World world, int x, int y, int z){
return tag;
}
public static void register(IWailaRegistrar registrar){
Util.logInfo("Initializing Waila Plugin...");
2015-05-20 22:39:43 +02:00
WailaDataProvider provider = new WailaDataProvider();
registrar.registerBodyProvider(provider, BlockCompost.class);
for(Block theBlock : registerList){
registrar.registerHeadProvider(provider, theBlock.getClass());
}
2015-04-26 20:07:57 +02:00
}
}