Skip to content

Commit

Permalink
Added WAILA support for water plants. Fixed WAILA header for some ore…
Browse files Browse the repository at this point in the history
…s not using white text.
  • Loading branch information
Kittychanley committed Nov 14, 2015
1 parent 48191cc commit 8997d84
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 19 deletions.
76 changes: 57 additions & 19 deletions src/Common/com/bioxx/tfc/WAILA/WAILAData.java
Expand Up @@ -11,6 +11,7 @@
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;

import net.minecraftforge.fluids.FluidStack;
Expand All @@ -22,6 +23,7 @@
import com.bioxx.tfc.Blocks.Flora.BlockBerryBush;
import com.bioxx.tfc.Blocks.Flora.BlockFruitLeaves;
import com.bioxx.tfc.Blocks.Flora.BlockFruitWood;
import com.bioxx.tfc.Blocks.Flora.BlockWaterPlant;
import com.bioxx.tfc.Blocks.Terrain.*;
import com.bioxx.tfc.Blocks.Vanilla.BlockCustomDoor;
import com.bioxx.tfc.Blocks.Vanilla.BlockTorch;
Expand Down Expand Up @@ -53,12 +55,15 @@ public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler
Block block = accessor.getBlock();
TileEntity tileEntity = accessor.getTileEntity();

if (accessor.getBlock() instanceof BlockAnvil)
World world = accessor.getWorld();
MovingObjectPosition pos = accessor.getPosition();

if (block instanceof BlockAnvil)
return anvilStack(accessor, config);

else if (tileEntity instanceof TEBerryBush)
return berryBushStack(accessor, config);

else if (tileEntity instanceof TEBloom)
return new ItemStack(TFCItems.rawBloom);

Expand All @@ -73,7 +78,7 @@ else if (block instanceof BlockCobble)

else if (tileEntity instanceof TECrop)
return cropStack(accessor, config);

else if (block instanceof BlockCustomDoor)
return new ItemStack(Recipes.doors[((BlockCustomDoor) block).getWoodType() / 2]);

Expand Down Expand Up @@ -103,7 +108,10 @@ else if (tileEntity instanceof TEOre)

else if (block instanceof BlockPartial)
return partialStack(accessor, config);


else if (block instanceof BlockWaterPlant && TFC_Core.isSaltWater(world.getBlock(pos.blockX, pos.blockY + 1, pos.blockZ))) // Sea Weed
return ItemFoodTFC.createTag(new ItemStack(TFCItems.seaWeed, 1, 0));

else if (tileEntity instanceof TEWorldItem)
return worldItemStack(accessor, config);

Expand All @@ -113,8 +121,10 @@ else if (tileEntity instanceof TEWorldItem)
@Override
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config)
{
Block block = accessor.getBlock();
TileEntity tileEntity = accessor.getTileEntity();
if (accessor.getTileEntity() instanceof TEBarrel)

if (tileEntity instanceof TEBarrel)
currenttip = barrelHead(itemStack, currenttip, accessor, config);

else if (tileEntity instanceof TEFruitLeaves)
Expand All @@ -129,6 +139,9 @@ else if (tileEntity instanceof TEOre)
else if (tileEntity instanceof TESmokeRack)
currenttip.set(0, EnumChatFormatting.WHITE.toString() + TFC_Core.translate("tile.SmokeRack.name"));

else if (block instanceof BlockWaterPlant)
currenttip = waterPlantHead(itemStack, currenttip, accessor, config);

return currenttip;
}

Expand Down Expand Up @@ -200,7 +213,7 @@ else if (tileEntity instanceof TESluice)

else if (tileEntity instanceof TESmokeRack)
currenttip = smokeRackBody(itemStack, currenttip, accessor, config);

else if (TFC_Core.isSoilWAILA(block))
currenttip = soilBody(itemStack, currenttip, accessor, config);

Expand Down Expand Up @@ -332,6 +345,9 @@ public static void callbackRegister(IWailaRegistrar reg)
reg.registerBodyProvider(new WAILAData(), BlockTorch.class);
reg.registerNBTProvider(new WAILAData(), BlockTorch.class);

reg.registerStackProvider(new WAILAData(), BlockWaterPlant.class);
reg.registerHeadProvider(new WAILAData(), BlockWaterPlant.class);

reg.registerStackProvider(new WAILAData(), TEWorldItem.class);
reg.registerNBTProvider(new WAILAData(), TEWorldItem.class);
}
Expand All @@ -345,7 +361,7 @@ public ItemStack anvilStack(IWailaDataAccessor accessor, IWailaConfigHandler con

return new ItemStack(block, 1, type);
}

public ItemStack berryBushStack(IWailaDataAccessor accessor, IWailaConfigHandler config)
{
NBTTagCompound tag = accessor.getNBTData();
Expand Down Expand Up @@ -544,22 +560,44 @@ public List<String> oreHead(ItemStack itemStack, List<String> currenttip, IWaila
{
if (meta == 14)
{
currenttip.set(0, TFC_Core.translate("item.Ore.Bituminous Coal.name"));
currenttip.set(0, EnumChatFormatting.WHITE.toString() + TFC_Core.translate("item.Ore.Bituminous Coal.name"));
}
else if (meta == 15)
{
currenttip.set(0, TFC_Core.translate("item.Ore.Lignite.name"));
currenttip.set(0, EnumChatFormatting.WHITE.toString() + TFC_Core.translate("item.Ore.Lignite.name"));
}
}
else if (accessor.getBlock() == TFCBlocks.ore2)
{
if (meta == 5)
{
currenttip.set(0, TFC_Core.translate("item.Ore.Kimberlite.name"));
currenttip.set(0, EnumChatFormatting.WHITE.toString() + TFC_Core.translate("item.Ore.Kimberlite.name"));
}
else if (meta == 13)
{
currenttip.set(0, TFC_Core.translate("item.Ore.Saltpeter.name"));
currenttip.set(0, EnumChatFormatting.WHITE.toString() + TFC_Core.translate("item.Ore.Saltpeter.name"));
}
}

return currenttip;
}

public List<String> waterPlantHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config)
{
MovingObjectPosition pos = accessor.getPosition();
World world = accessor.getWorld();
Block blockDirectlyAbove = world.getBlock(pos.blockX, pos.blockY + 1, pos.blockZ);
boolean airTwoAbove = world.isAirBlock(pos.blockX, pos.blockY + 2, pos.blockZ);

if (TFC_Core.isFreshWater(blockDirectlyAbove))
{
if (airTwoAbove)
{
currenttip.set(0, EnumChatFormatting.WHITE.toString() + TFC_Core.translate("tile.Flora.Cat Tails.name"));
}
else
{
currenttip.set(0, EnumChatFormatting.WHITE.toString() + TFC_Core.translate("tile.Flora.Pond Weed.name"));
}
}

Expand Down Expand Up @@ -595,7 +633,7 @@ public List<String> barrelBody(ItemStack itemStack, List<String> currenttip, IWa
FluidStack fluid = FluidStack.loadFluidStackFromNBT(tag.getCompoundTag("fluidNBT"));
BarrelRecipe recipe = BarrelManager.getInstance().findMatchingRecipe(inStack, fluid, sealed, te.getTechLevel());

if (sealed && fluid != null && fluid.getFluid() == TFCFluids.MILKCURDLED && (inStack == null ||
if (sealed && fluid != null && fluid.getFluid() == TFCFluids.MILKCURDLED && (inStack == null ||
inStack.getItem() instanceof IFood && ((IFood) inStack.getItem()).getFoodGroup() != EnumFoodGroup.Dairy && ((IFood) inStack.getItem()).isEdible(inStack) && Food.getWeight(inStack) <= 20.0f))
recipe = new BarrelRecipe(null, new FluidStack(TFCFluids.MILKCURDLED, 10000), ItemFoodTFC.createTag(new ItemStack(TFCItems.cheese, 1), 160), null).setMinTechLevel(0);

Expand All @@ -611,11 +649,11 @@ public List<String> barrelBody(ItemStack itemStack, List<String> currenttip, IWa
currenttip.add(TFC_Core.translate("gui.Barrel.SealedOn") + " : " + TFC_Time.getDateStringFromHours(sealTime));
}


// Output
BarrelPreservativeRecipe preservative = BarrelManager.getInstance().findMatchingPreservativeRepice(te, inStack, fluid, sealed);


if (recipe != null)
{
if (!(recipe instanceof BarrelBriningRecipe))
Expand Down Expand Up @@ -649,7 +687,7 @@ else if (Food.isPickled(inStack) && Food.getWeight(inStack) / fluid.amount <= Gl

return currenttip;
}

public List<String> berryBushBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config)
{
FloraIndex index = FloraManager.getInstance().findMatchingIndex(BlockBerryBush.metaNames[accessor.getMetadata()]);
Expand Down Expand Up @@ -889,7 +927,7 @@ public List<String> loomBody(ItemStack itemStack, List<String> currenttip, IWail
boolean finished = tag.getBoolean("finished");
int wovenStrings = tag.getInteger("cloth");
ItemStack storage[] = getStorage(tag, accessor.getTileEntity());

if (!finished && storage[0] != null)
{
LoomRecipe recipe = LoomManager.getInstance().findPotentialRecipes(storage[0]);
Expand Down Expand Up @@ -1099,14 +1137,14 @@ public List<String> sluiceBody(ItemStack itemStack, List<String> currenttip, IWa
NBTTagCompound tag = accessor.getNBTData();
ItemStack storage[] = getStorage(tag, accessor.getTileEntity());
int soilAmount = tag.getInteger("soilAmount");

if (soilAmount == -1)
currenttip.add(TFC_Core.translate("gui.Sluice.Overworked"));
else if (soilAmount > 0)
{
currenttip.add(TFC_Core.translate("gui.Sluice.Soil") + " : " + soilAmount + "/50");
}

int gemCount = 0, oreCount = 0;
for (ItemStack is : storage)
{
Expand All @@ -1118,7 +1156,7 @@ else if (is.getItem() instanceof ItemOre)
oreCount++;
}
}

if (gemCount > 0)
currenttip.add(TFC_Core.translate("gui.gems") + " : " + gemCount);
if (oreCount > 0)
Expand Down
1 change: 1 addition & 0 deletions src/Resources/assets/terrafirmacraft/lang/en_US.lang
Expand Up @@ -2127,6 +2127,7 @@ tile.Moss.name=Moss
tile.Thatch.name=Thatch
tile.Flora.Golden Rod.name=Goldenrod
tile.Flora.Cat Tails.name=Cattails
tile.Flora.Pond Weed.name=Pond Weed

item.Seeds Sugarcane.name=Sugarcane Seeds
item.Seeds Hemp.name=Hemp Seeds
Expand Down

0 comments on commit 8997d84

Please sign in to comment.