2016-05-31 16:43:11 -07:00
|
|
|
package WayofTime.bloodmagic.compat.waila.provider;
|
|
|
|
|
2018-02-15 18:49:01 -08:00
|
|
|
import WayofTime.bloodmagic.util.Constants;
|
2018-03-04 09:17:23 -08:00
|
|
|
import WayofTime.bloodmagic.ritual.imperfect.ImperfectRitualRegistry;
|
|
|
|
import WayofTime.bloodmagic.ritual.RitualRegistry;
|
|
|
|
import WayofTime.bloodmagic.ritual.imperfect.ImperfectRitual;
|
2018-02-15 18:49:01 -08:00
|
|
|
import WayofTime.bloodmagic.util.helper.PlayerHelper;
|
2016-05-31 16:43:11 -07:00
|
|
|
import WayofTime.bloodmagic.tile.TileMasterRitualStone;
|
|
|
|
import WayofTime.bloodmagic.util.helper.TextHelper;
|
2017-08-15 21:30:48 -07:00
|
|
|
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.ItemStack;
|
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
|
|
import net.minecraft.tileentity.TileEntity;
|
|
|
|
import net.minecraft.util.math.BlockPos;
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
|
2018-02-08 19:01:12 -08:00
|
|
|
import javax.annotation.Nonnull;
|
2017-08-15 21:30:48 -07:00
|
|
|
import java.util.List;
|
2016-05-31 16:43:11 -07:00
|
|
|
|
2017-08-15 21:30:48 -07:00
|
|
|
public class DataProviderRitualController implements IWailaDataProvider {
|
2016-05-31 16:43:11 -07:00
|
|
|
|
2018-02-08 19:01:12 -08:00
|
|
|
public static final IWailaDataProvider INSTANCE = new DataProviderRitualController();
|
2016-05-31 16:43:11 -07:00
|
|
|
|
2018-02-08 19:01:12 -08:00
|
|
|
@Nonnull
|
2016-05-31 16:43:11 -07:00
|
|
|
@Override
|
2017-08-15 21:30:48 -07:00
|
|
|
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
2016-05-31 16:43:11 -07:00
|
|
|
if (!config.getConfig(Constants.Compat.WAILA_CONFIG_RITUAL))
|
|
|
|
return currenttip;
|
|
|
|
|
2018-02-08 19:01:12 -08:00
|
|
|
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"));
|
2017-08-15 21:30:48 -07:00
|
|
|
} else {
|
2018-02-08 19:01:12 -08:00
|
|
|
if (tag.hasKey("ritual")) {
|
|
|
|
currenttip.add(TextHelper.localizeEffect(tag.getString("ritual")));
|
|
|
|
if (!tag.getBoolean("enabled"))
|
|
|
|
currenttip.add(TextHelper.localizeEffect("tooltip.bloodmagic.config.disabled"));
|
|
|
|
}
|
2016-05-31 16:43:11 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return currenttip;
|
|
|
|
}
|
|
|
|
|
2018-02-08 19:01:12 -08:00
|
|
|
@Nonnull
|
2016-05-31 16:43:11 -07:00
|
|
|
@Override
|
2017-08-15 21:30:48 -07:00
|
|
|
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) {
|
2018-02-08 19:01:12 -08:00
|
|
|
|
|
|
|
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());
|
2018-02-27 16:59:51 -08:00
|
|
|
if (mrs.getOwner() != null)
|
2018-02-08 19:01:12 -08:00
|
|
|
tag.setString("owner", PlayerHelper.getUsernameFromUUID(mrs.getOwner()));
|
|
|
|
tag.setBoolean("enabled", RitualRegistry.ritualEnabled(mrs.getCurrentRitual()));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
tag.setBoolean("master", false);
|
|
|
|
|
2018-03-04 09:17:23 -08:00
|
|
|
ImperfectRitual ritual = ImperfectRitualRegistry.getRitualForBlock(world.getBlockState(pos.up()));
|
2018-02-08 19:01:12 -08:00
|
|
|
if (ritual != null) {
|
|
|
|
tag.setString("ritual", ritual.getUnlocalizedName());
|
|
|
|
tag.setBoolean("enabled", ImperfectRitualRegistry.ritualEnabled(ritual));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return tag;
|
2016-05-31 16:43:11 -07:00
|
|
|
}
|
|
|
|
}
|