Rewrite Hwyla integration

Now properly makes use of the API
This commit is contained in:
Nicholas Ignoffo 2018-02-08 19:01:12 -08:00
parent 9f6a4983a6
commit 03fece58fa
9 changed files with 187 additions and 201 deletions

View file

@ -148,7 +148,6 @@ public class Constants {
public static final String JEI_CATEGORY_ALCHEMYTABLE = BloodMagic.MODID + ":salchemyTable";
public static final String JEI_CATEGORY_ARMOURDOWNGRADE = BloodMagic.MODID + ":armourDowngrade";
public static final String WAILA_CONFIG_BYPASS_SNEAK = BloodMagic.MODID + ".bypassSneak";
public static final String WAILA_CONFIG_ALTAR = BloodMagic.MODID + ".bloodAltar";
public static final String WAILA_CONFIG_TELEPOSER = BloodMagic.MODID + ".teleposer";
public static final String WAILA_CONFIG_RITUAL = BloodMagic.MODID + ".ritualController";

View file

@ -2,8 +2,8 @@ package WayofTime.bloodmagic.compat.waila;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.apibutnotreally.Constants;
import WayofTime.bloodmagic.block.*;
import WayofTime.bloodmagic.compat.waila.provider.*;
import WayofTime.bloodmagic.tile.*;
import mcp.mobius.waila.api.IWailaPlugin;
import mcp.mobius.waila.api.IWailaRegistrar;
import mcp.mobius.waila.api.WailaPlugin;
@ -13,22 +13,30 @@ public class BloodMagicHwylaPlugin implements IWailaPlugin {
@Override
public void register(IWailaRegistrar registrar) {
registrar.registerBodyProvider(new DataProviderBloodAltar(), BlockAltar.class);
registrar.registerNBTProvider(new DataProviderBloodAltar(), BlockAltar.class);
registrar.registerBodyProvider(new DataProviderTeleposer(), BlockTeleposer.class);
registrar.registerBodyProvider(new DataProviderRitualController(), BlockRitualController.class);
registrar.registerBodyProvider(new DataProviderAlchemyArray(), BlockAlchemyArray.class);
registrar.registerBodyProvider(new DataProviderBloodTank(), BlockBloodTank.class);
registrar.registerNBTProvider(new DataProviderBloodTank(), BlockBloodTank.class);
registrar.registerStackProvider(new DataProviderAlchemyArray(), BlockAlchemyArray.class);
registrar.registerStackProvider(new DataProviderMimic(), BlockMimic.class);
registrar.registerNBTProvider(new DataProviderMimic(), BlockMimic.class);
registrar.addConfig(BloodMagic.MODID, Constants.Compat.WAILA_CONFIG_BYPASS_SNEAK, false);
registrar.registerBodyProvider(DataProviderBloodAltar.INSTANCE, TileAltar.class);
registrar.registerNBTProvider(DataProviderBloodAltar.INSTANCE, TileAltar.class);
registrar.addConfig(BloodMagic.MODID, Constants.Compat.WAILA_CONFIG_ALTAR, true);
registrar.registerBodyProvider(DataProviderTeleposer.INSTANCE, TileTeleposer.class);
registrar.registerNBTProvider(DataProviderTeleposer.INSTANCE, TileTeleposer.class);
registrar.addConfig(BloodMagic.MODID, Constants.Compat.WAILA_CONFIG_TELEPOSER, true);
registrar.registerBodyProvider(DataProviderRitualController.INSTANCE, TileMasterRitualStone.class);
registrar.registerNBTProvider(DataProviderRitualController.INSTANCE, TileMasterRitualStone.class);
registrar.registerBodyProvider(DataProviderRitualController.INSTANCE, TileImperfectRitualStone.class);
registrar.registerNBTProvider(DataProviderRitualController.INSTANCE, TileImperfectRitualStone.class);
registrar.addConfig(BloodMagic.MODID, Constants.Compat.WAILA_CONFIG_RITUAL, true);
registrar.addConfig(BloodMagic.MODID, Constants.Compat.WAILA_CONFIG_ARRAY, true);
registrar.registerBodyProvider(DataProviderBloodTank.INSTANCE, TileBloodTank.class);
registrar.registerNBTProvider(DataProviderBloodTank.INSTANCE, TileBloodTank.class);
registrar.addConfig(BloodMagic.MODID, Constants.Compat.WAILA_CONFIG_BLOOD_TANK, true);
registrar.registerStackProvider(DataProviderAlchemyArray.INSTANCE, TileAlchemyArray.class);
registrar.registerBodyProvider(DataProviderAlchemyArray.INSTANCE, TileAlchemyArray.class);
registrar.registerNBTProvider(DataProviderAlchemyArray.INSTANCE, TileAlchemyArray.class);
registrar.addConfig(BloodMagic.MODID, Constants.Compat.WAILA_CONFIG_ARRAY, true);
registrar.registerStackProvider(DataProviderMimic.INSTANCE, TileMimic.class);
registrar.registerNBTProvider(DataProviderMimic.INSTANCE, TileMimic.class);
}
}

View file

@ -15,48 +15,41 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
import java.util.List;
public class DataProviderAlchemyArray implements IWailaDataProvider {
public static final IWailaDataProvider INSTANCE = new DataProviderAlchemyArray();
@Nonnull
@Override
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
return new ItemStack(RegistrarBloodMagicItems.ARCANE_ASHES).setStackDisplayName(TextHelper.getFormattedText(RegistrarBloodMagicBlocks.ALCHEMY_ARRAY.getLocalizedName()));
}
@Override
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
return null;
}
@Nonnull
@Override
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
if (!config.getConfig(Constants.Compat.WAILA_CONFIG_ARRAY))
return currenttip;
if (accessor.getPlayer().isSneaking() || config.getConfig(Constants.Compat.WAILA_CONFIG_BYPASS_SNEAK)) {
TileEntity tile = accessor.getTileEntity();
if (tile instanceof TileAlchemyArray) {
TileAlchemyArray tileArray = (TileAlchemyArray) tile;
if (!tileArray.getStackInSlot(0).isEmpty())
currenttip.add(TextHelper.localize("waila.bloodmagic.array.reagent", tileArray.getStackInSlot(0).getDisplayName()));
if (!tileArray.getStackInSlot(1).isEmpty())
currenttip.add(TextHelper.localize("waila.bloodmagic.array.catalyst", tileArray.getStackInSlot(1).getDisplayName()));
}
} else {
currenttip.add(TextHelper.localizeEffect("waila.bloodmagic.sneak"));
}
if (accessor.getNBTData().hasKey("reagent"))
currenttip.add(TextHelper.localize("waila.bloodmagic.array.reagent", accessor.getNBTData().getString("reagent")));
if (accessor.getNBTData().hasKey("catalyst"))
currenttip.add(TextHelper.localize("waila.bloodmagic.array.catalyst", accessor.getNBTData().getString("catalyst")));
return currenttip;
}
@Override
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
return null;
}
@Nonnull
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) {
return null;
TileAlchemyArray alchemyArray = (TileAlchemyArray) te;
if (!alchemyArray.getStackInSlot(0).isEmpty())
tag.setString("reagent", alchemyArray.getStackInSlot(0).getDisplayName());
if (!alchemyArray.getStackInSlot(1).isEmpty())
tag.setString("catalyst", alchemyArray.getStackInSlot(1).getDisplayName());
return tag;
}
}

View file

@ -19,6 +19,7 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
import java.util.List;
/**
@ -27,11 +28,35 @@ import java.util.List;
* in ImLookingAtBlood by <a href="https://github.com/Pokefenn">Pokefenn</a>.
*/
public class DataProviderBloodAltar implements IWailaDataProvider {
public static final IWailaDataProvider INSTANCE = new DataProviderBloodAltar();
@Nonnull
@Override
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
if (!config.getConfig(Constants.Compat.WAILA_CONFIG_ALTAR))
return currenttip;
if (accessor.getNBTData().hasKey("altar")) {
NBTTagCompound altarData = accessor.getNBTData().getCompoundTag("altar");
currenttip.add(TextHelper.localizeEffect("tooltip.bloodmagic.sigil.seer.currentAltarTier", altarData.getInteger("tier")));
currenttip.add(TextHelper.localizeEffect("tooltip.bloodmagic.sigil.seer.currentAltarCapacity", altarData.getInteger("capacity")));
currenttip.add(TextHelper.localizeEffect("tooltip.bloodmagic.sigil.seer.currentEssence", altarData.getInteger("stored")));
if (altarData.hasKey("charge")) {
currenttip.add(TextHelper.localizeEffect("tooltip.bloodmagic.sigil.seer.currentAltarProgress.percent", altarData.getInteger("progress") + "%"));
currenttip.add(TextHelper.localizeEffect("tooltip.bloodmagic.sigil.seer.currentCharge", altarData.getInteger("charge")));
}
}
return currenttip;
}
@Nonnull
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) {
TileAltar altar = (TileAltar) te;
boolean hasSigil = false;
boolean hasSeer = false;
@ -41,49 +66,31 @@ public class DataProviderBloodAltar implements IWailaDataProvider {
break;
}
case SIGIL_HELD: {
hasSeer = holdingSeerSigil(accessor.getPlayer());
hasSigil = hasSeer || holdingDivinationSigil(accessor.getPlayer());
hasSeer = holdingSeerSigil(player);
hasSigil = hasSeer || holdingDivinationSigil(player);
break;
}
case SIGIL_CONTAINED: {
hasSeer = hasStack(new ItemStack(RegistrarBloodMagicItems.SIGIL_SEER), accessor.getPlayer());
hasSigil = hasSeer || hasStack(new ItemStack(RegistrarBloodMagicItems.SIGIL_DIVINATION), accessor.getPlayer());
hasSeer = hasStack(new ItemStack(RegistrarBloodMagicItems.SIGIL_SEER), player);
hasSigil = hasSeer || hasStack(new ItemStack(RegistrarBloodMagicItems.SIGIL_DIVINATION), player);
break;
}
}
if (!hasSeer && !hasSigil)
return currenttip;
return tag;
if (accessor.getPlayer().isSneaking() || config.getConfig(Constants.Compat.WAILA_CONFIG_BYPASS_SNEAK)) {
if (accessor.getBlock() instanceof BlockAltar && accessor.getTileEntity() instanceof TileAltar) {
TileAltar altar = (TileAltar) accessor.getTileEntity();
currenttip.add(TextHelper.localizeEffect("tooltip.bloodmagic.sigil.seer.currentAltarTier", altar.getTier().toInt()));
currenttip.add(TextHelper.localizeEffect("tooltip.bloodmagic.sigil.seer.currentAltarCapacity", altar.getCapacity()));
currenttip.add(TextHelper.localizeEffect("tooltip.bloodmagic.sigil.seer.currentEssence", altar.getCurrentBlood()));
if (hasSeer) {
int charge = accessor.getNBTData().getCompoundTag("bloodAltar").getInteger(Constants.NBT.ALTAR_TOTAL_CHARGE);
int progress = accessor.getNBTData().getCompoundTag("bloodAltar").getInteger(Constants.NBT.ALTAR_PROGRESS);
int liquidRequired = accessor.getNBTData().getCompoundTag("bloodAltar").getInteger(Constants.NBT.ALTAR_LIQUID_REQ);
int craftAmount = 1;
if (accessor.getNBTData().getTagList("Items", 10).get(0).getId() == 10)
craftAmount = ((NBTTagCompound) accessor.getNBTData().getTagList("Items", 10).get(0)).getByte("Count");
currenttip.add(TextHelper.localizeEffect("tooltip.bloodmagic.sigil.seer.currentAltarProgress.percent", (int) (((double) progress / (double) liquidRequired * 100) / craftAmount) + "%"));
currenttip.add(TextHelper.localizeEffect("tooltip.bloodmagic.sigil.seer.currentCharge", charge));
}
}
} else {
currenttip.add(TextHelper.localizeEffect("waila.bloodmagic.sneak"));
NBTTagCompound altarData = new NBTTagCompound();
altarData.setInteger("tier", altar.getTier().toInt());
altarData.setInteger("capacity", altar.getCapacity());
altarData.setInteger("stored", altar.getCurrentBlood());
if (hasSeer) {
altarData.setInteger("progress", (int) (((double) altar.getProgress() / (double) altar.getLiquidRequired() * 100) / altar.getStackInSlot(0).getCount()));
altarData.setInteger("charge", altar.getTotalCharge());
}
return currenttip;
}
tag.setTag("altar", altarData);
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) {
if (te != null)
te.writeToNBT(tag);
return tag;
}

View file

@ -1,7 +1,6 @@
package WayofTime.bloodmagic.compat.waila.provider;
import WayofTime.bloodmagic.apibutnotreally.Constants;
import WayofTime.bloodmagic.block.BlockBloodTank;
import WayofTime.bloodmagic.tile.TileBloodTank;
import WayofTime.bloodmagic.util.helper.TextHelper;
import mcp.mobius.waila.api.IWailaConfigHandler;
@ -15,54 +14,38 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fluids.FluidStack;
import javax.annotation.Nonnull;
import java.util.List;
public class DataProviderBloodTank implements IWailaDataProvider {
@Override
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
return null;
}
@Override
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
return null;
}
public static final IWailaDataProvider INSTANCE = new DataProviderBloodTank();
@Nonnull
@Override
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
if (!config.getConfig(Constants.Compat.WAILA_CONFIG_BLOOD_TANK) && !config.getConfig("capability.tankinfo"))
return currenttip;
if (accessor.getPlayer().isSneaking() || config.getConfig(Constants.Compat.WAILA_CONFIG_BYPASS_SNEAK)) {
if (accessor.getBlock() instanceof BlockBloodTank && accessor.getTileEntity() instanceof TileBloodTank) {
TileBloodTank bloodTank = (TileBloodTank) accessor.getTileEntity();
NBTTagCompound tag = accessor.getNBTData();
int capacity = accessor.getNBTData().getInteger(Constants.NBT.ALTAR_CAPACITY);
currenttip.add(TextHelper.localizeEffect("tooltip.bloodmagic.tier", bloodTank.getBlockMetadata() + 1));
currenttip.add(TextHelper.localizeEffect("tooltip.bloodmagic.fluid.capacity", capacity));
FluidStack fluidStack = FluidStack.loadFluidStackFromNBT(tag.getCompoundTag(Constants.NBT.TANK));
if (fluidStack != null) {
currenttip.add(TextHelper.localizeEffect("tooltip.bloodmagic.fluid.type", fluidStack.getLocalizedName()));
currenttip.add(TextHelper.localizeEffect("tooltip.bloodmagic.fluid.amount", fluidStack.amount, capacity));
}
}
} else {
currenttip.add(TextHelper.localizeEffect("waila.bloodmagic.sneak"));
currenttip.add(TextHelper.localizeEffect("tooltip.bloodmagic.tier", accessor.getNBTData().getInteger("tier")));
currenttip.add(TextHelper.localizeEffect("tooltip.bloodmagic.fluid.capacity", accessor.getNBTData().getInteger("capacity")));
if (accessor.getNBTData().hasKey("fluid")) {
FluidStack fluidStack = FluidStack.loadFluidStackFromNBT(accessor.getNBTData().getCompoundTag("fluid"));
currenttip.add(TextHelper.localizeEffect("tooltip.bloodmagic.fluid.type", fluidStack.getLocalizedName()));
currenttip.add(TextHelper.localizeEffect("tooltip.bloodmagic.fluid.amount", fluidStack.amount, accessor.getNBTData().getInteger("capacity")));
}
return currenttip;
}
@Override
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
return null;
}
@Nonnull
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) {
if (te != null)
te.writeToNBT(tag);
TileBloodTank tank = (TileBloodTank) te;
tag.setInteger("tier", tank.getBlockMetadata() + 1);
tag.setInteger("capacity", tank.capacity);
if (tank.getTank().getFluid() != null)
tag.setTag("fluid", tank.getTank().getFluid().writeToNBT(new NBTTagCompound()));
return tag;
}
}

View file

@ -5,44 +5,53 @@ import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.registry.ForgeRegistries;
import javax.annotation.Nonnull;
import java.util.List;
public class DataProviderMimic implements IWailaDataProvider {
public static final IWailaDataProvider INSTANCE = new DataProviderMimic();
@Nonnull
@Override
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
if (accessor.getNBTData().getBoolean("hasItem"))
return new ItemStack(accessor.getNBTData());
if (accessor.getNBTData().hasKey("mimiced")) {
NBTTagCompound mimiced = accessor.getNBTData().getCompoundTag("mimiced");
Item item = ForgeRegistries.ITEMS.getValue(new ResourceLocation(mimiced.getString("id")));
int meta = mimiced.getInteger("data");
ItemStack ret = new ItemStack(item, 1, meta);
if (mimiced.hasKey("nbt"))
ret.setTagCompound(mimiced.getCompoundTag("nbt"));
return new ItemStack(accessor.getBlock(), 1, accessor.getMetadata());
}
@Override
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
return null;
}
@Override
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
return null;
}
@Override
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
return null;
return ret;
}
return ItemStack.EMPTY;
}
@Nonnull
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) {
if (te instanceof TileMimic && ((TileMimic) te).getStackInSlot(0) != null) {
tag.setBoolean("hasItem", true);
((TileMimic) te).getStackInSlot(0).writeToNBT(tag);
TileMimic mimic = (TileMimic) te;
ItemStack mimiced = mimic.getStackInSlot(0);
if (!mimiced.isEmpty()) {
NBTTagCompound item = new NBTTagCompound();
item.setString("id", mimiced.getItem().getRegistryName().toString());
item.setInteger("data", mimiced.getMetadata());
NBTTagCompound shareTag = mimiced.getItem().getNBTShareTag(mimiced);
if (shareTag != null)
item.setTag("nbt", shareTag);
tag.setTag("mimiced", item);
}
return tag;
}

View file

@ -6,14 +6,12 @@ import WayofTime.bloodmagic.apibutnotreally.registry.ImperfectRitualRegistry;
import WayofTime.bloodmagic.apibutnotreally.registry.RitualRegistry;
import WayofTime.bloodmagic.apibutnotreally.ritual.imperfect.ImperfectRitual;
import WayofTime.bloodmagic.apibutnotreally.util.helper.PlayerHelper;
import WayofTime.bloodmagic.block.BlockRitualController;
import WayofTime.bloodmagic.tile.TileImperfectRitualStone;
import WayofTime.bloodmagic.tile.TileMasterRitualStone;
import WayofTime.bloodmagic.util.helper.TextHelper;
import joptsimple.internal.Strings;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@ -21,70 +19,64 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
import java.util.List;
public class DataProviderRitualController implements IWailaDataProvider {
@Override
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
return null;
}
@Override
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
return null;
}
public static final IWailaDataProvider INSTANCE = new DataProviderRitualController();
@Nonnull
@Override
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
if (!config.getConfig(Constants.Compat.WAILA_CONFIG_RITUAL))
return currenttip;
if (accessor.getPlayer().isSneaking() || config.getConfig(Constants.Compat.WAILA_CONFIG_BYPASS_SNEAK)) {
if (accessor.getBlock() instanceof BlockRitualController) {
int controllerMeta = accessor.getBlock().getMetaFromState(accessor.getBlockState());
if ((controllerMeta == 0 || controllerMeta == 2) && accessor.getTileEntity() instanceof TileMasterRitualStone) {
TileMasterRitualStone mrs = (TileMasterRitualStone) accessor.getTileEntity();
if (mrs.getCurrentRitual() != null && mrs.isActive()) {
currenttip.add(TextHelper.localizeEffect(mrs.getCurrentRitual().getUnlocalizedName()));
currenttip.add(TextHelper.localizeEffect("tooltip.bloodmagic.currentOwner", PlayerHelper.getUsernameFromUUID(mrs.getOwner())));
if (!RitualRegistry.ritualEnabled(mrs.getCurrentRitual()))
currenttip.add(TextHelper.localizeEffect("tooltip.bloodmagic.config.disabled"));
} else {
currenttip.add(TextHelper.localizeEffect("tooltip.bloodmagic.deactivated"));
}
}
if (controllerMeta == 1 && accessor.getTileEntity() instanceof TileImperfectRitualStone) {
if (accessor.getWorld().isAirBlock(accessor.getPosition().up())) {
Block up = accessor.getWorld().getBlockState(accessor.getPosition().up()).getBlock();
int meta = up.getMetaFromState(accessor.getWorld().getBlockState(accessor.getPosition().up()));
BlockStack blockStack = new BlockStack(up, meta);
ImperfectRitual ritual = ImperfectRitualRegistry.getRitualForBlock(blockStack);
if (ritual != null) {
currenttip.add(TextHelper.localizeEffect(ritual.getUnlocalizedName()));
if (!ImperfectRitualRegistry.ritualEnabled(ritual))
currenttip.add(TextHelper.localizeEffect("tooltip.bloodmagic.config.disabled"));
}
}
}
}
NBTTagCompound tag = accessor.getNBTData();
if (tag.getBoolean("master")) {
if (tag.hasKey("ritual"))
currenttip.add(TextHelper.localizeEffect(tag.getString("ritual")));
if (tag.hasKey("owner"))
currenttip.add(TextHelper.localizeEffect("tooltip.bloodmagic.currentOwner", tag.getString("owner")));
if (!tag.getBoolean("active"))
currenttip.add(TextHelper.localizeEffect("tooltip.bloodmagic.deactivated"));
if (!tag.getBoolean("enabled"))
currenttip.add(TextHelper.localizeEffect("tooltip.bloodmagic.config.disabled"));
} else {
currenttip.add(TextHelper.localizeEffect("waila.bloodmagic.sneak"));
if (tag.hasKey("ritual")) {
currenttip.add(TextHelper.localizeEffect(tag.getString("ritual")));
if (!tag.getBoolean("enabled"))
currenttip.add(TextHelper.localizeEffect("tooltip.bloodmagic.config.disabled"));
}
}
return currenttip;
}
@Override
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
return null;
}
@Nonnull
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) {
return null;
if (te instanceof TileMasterRitualStone) {
TileMasterRitualStone mrs = (TileMasterRitualStone) te;
tag.setBoolean("master", true);
if (mrs.getCurrentRitual() != null) {
tag.setString("ritual", mrs.getCurrentRitual().getUnlocalizedName());
tag.setBoolean("active", mrs.isActive());
if (!Strings.isNullOrEmpty(mrs.getOwner()))
tag.setString("owner", PlayerHelper.getUsernameFromUUID(mrs.getOwner()));
tag.setBoolean("enabled", RitualRegistry.ritualEnabled(mrs.getCurrentRitual()));
}
} else {
tag.setBoolean("master", false);
ImperfectRitual ritual = ImperfectRitualRegistry.getRitualForBlock(BlockStack.getStackFromPos(world, pos.up()));
if (ritual != null) {
tag.setString("ritual", ritual.getUnlocalizedName());
tag.setBoolean("enabled", ImperfectRitualRegistry.ritualEnabled(ritual));
}
}
return tag;
}
}

View file

@ -1,7 +1,6 @@
package WayofTime.bloodmagic.compat.waila.provider;
import WayofTime.bloodmagic.apibutnotreally.Constants;
import WayofTime.bloodmagic.block.BlockTeleposer;
import WayofTime.bloodmagic.item.ItemTelepositionFocus;
import WayofTime.bloodmagic.tile.TileTeleposer;
import WayofTime.bloodmagic.util.helper.TextHelper;
@ -11,54 +10,49 @@ import mcp.mobius.waila.api.IWailaDataProvider;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTUtil;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.DimensionManager;
import org.apache.commons.lang3.text.WordUtils;
import javax.annotation.Nonnull;
import java.util.List;
public class DataProviderTeleposer implements IWailaDataProvider {
@Override
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
return null;
}
@Override
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
return null;
}
public static final IWailaDataProvider INSTANCE = new DataProviderTeleposer();
@Nonnull
@Override
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
if (!config.getConfig(Constants.Compat.WAILA_CONFIG_TELEPOSER))
return currenttip;
if (accessor.getPlayer().isSneaking() || config.getConfig(Constants.Compat.WAILA_CONFIG_BYPASS_SNEAK)) {
if (accessor.getBlock() instanceof BlockTeleposer && accessor.getTileEntity() instanceof TileTeleposer) {
TileTeleposer teleposer = (TileTeleposer) accessor.getTileEntity();
if (!teleposer.getStackInSlot(0).isEmpty()) {
ItemStack contained = teleposer.getStackInSlot(0);
BlockPos toPos = ((ItemTelepositionFocus) contained.getItem()).getBlockPos(contained);
int dimensionID = contained.getTagCompound().getInteger(Constants.NBT.DIMENSION_ID);
if (accessor.getNBTData().hasKey("focus")) {
NBTTagCompound focusData = accessor.getNBTData().getCompoundTag("focus");
BlockPos boundPos = NBTUtil.getPosFromTag(focusData.getCompoundTag("pos"));
int boundDim = focusData.getInteger("dim");
String dimName = WordUtils.capitalizeFully(DimensionManager.getProviderType(boundDim).getName().replace("_", " "));
currenttip.add(TextHelper.localizeEffect("tooltip.bloodmagic.telepositionFocus.coords", toPos.getX(), toPos.getY(), toPos.getZ()));
currenttip.add(TextHelper.localizeEffect("tooltip.bloodmagic.telepositionFocus.dimension", dimensionID));
}
}
} else {
currenttip.add(TextHelper.localizeEffect("waila.bloodmagic.sneak"));
currenttip.add(TextHelper.localizeEffect("tooltip.bloodmagic.telepositionFocus.bound", dimName, boundPos.getX(), boundPos.getY(), boundPos.getZ()));
}
return currenttip;
}
@Override
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
return null;
}
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) {
return null;
TileTeleposer teleposer = (TileTeleposer) te;
ItemStack contained = teleposer.getStackInSlot(0);
if (!contained.isEmpty() && contained.hasTagCompound()) {
ItemTelepositionFocus focus = (ItemTelepositionFocus) contained.getItem();
NBTTagCompound focusData = new NBTTagCompound();
focusData.setTag("pos", NBTUtil.createPosTag(focus.getBlockPos(contained)));
focusData.setInteger("dim", contained.getTagCompound().getInteger(Constants.NBT.DIMENSION_ID));
tag.setTag("focus", focusData);
}
return tag;
}
}

View file

@ -469,6 +469,7 @@ tooltip.bloodmagic.arcaneAshes=Ashes used to draw an alchemy circle
tooltip.bloodmagic.telepositionFocus.coords=Current coordinates: (%d, %d, %d)
tooltip.bloodmagic.telepositionFocus.dimension=Dimension ID: %d
tooltip.bloodmagic.telepositionFocus.bound=Bound: %s at %d, %d, %d
tooltip.bloodmagic.telepositionFocus.weak=Used to move blocks in the world
tooltip.bloodmagic.telepositionFocus.enhanced=Used to move blocks in the world
tooltip.bloodmagic.telepositionFocus.reinforced=Used to move blocks in the world