Solar Panel re-implementation
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
package me.hypherionmc.hyperlighting.common.integration.wthit.dataproviders;
|
||||
|
||||
import mcp.mobius.waila.api.IPluginConfig;
|
||||
import mcp.mobius.waila.api.IServerAccessor;
|
||||
import mcp.mobius.waila.api.IServerDataProvider;
|
||||
import me.hypherionmc.hyperlighting.common.blockentities.SolarPanelBlockEntity;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
* @date 18/09/2022
|
||||
*/
|
||||
public class SolarPanelDataProvider implements IServerDataProvider<SolarPanelBlockEntity> {
|
||||
|
||||
@Override
|
||||
public void appendServerData(CompoundTag data, IServerAccessor<SolarPanelBlockEntity> accessor, IPluginConfig config) {
|
||||
CompoundTag tag = new CompoundTag();
|
||||
accessor.getTarget().saveAdditional(tag);
|
||||
data.put("hl_solar", tag);
|
||||
}
|
||||
}
|
@@ -0,0 +1,24 @@
|
||||
package me.hypherionmc.hyperlighting.common.integration.wthit.providers;
|
||||
|
||||
import mcp.mobius.waila.api.IBlockAccessor;
|
||||
import mcp.mobius.waila.api.IBlockComponentProvider;
|
||||
import mcp.mobius.waila.api.IPluginConfig;
|
||||
import mcp.mobius.waila.api.ITooltip;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
* @date 18/09/2022
|
||||
*/
|
||||
public class SolarPanelProvider implements IBlockComponentProvider {
|
||||
|
||||
@Override
|
||||
public void appendBody(ITooltip tooltip, IBlockAccessor accessor, IPluginConfig config) {
|
||||
CompoundTag compound = accessor.getServerData().getCompound("hl_solar");
|
||||
int powerLevel = compound.getInt("powerLevel");
|
||||
int level = (int) (((float) powerLevel / 2000) * 100);
|
||||
tooltip.addLine(Component.literal("Power Level : " + ChatFormatting.YELLOW + level + "%"));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user