Removed Hywla for now due to breaking our builds (#4421)

Once they provide a maven repo and a reliable backup, it will be added again.
This commit is contained in:
yueh
2020-06-18 16:02:24 +02:00
committed by GitHub
parent 65d4f2fd1a
commit 10ab5d0d5a
19 changed files with 2 additions and 1492 deletions
@@ -1,70 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.waila;
import java.util.List;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.world.World;
import mcp.mobius.waila.api.IComponentProvider;
import mcp.mobius.waila.api.IDataAccessor;
import mcp.mobius.waila.api.IPluginConfig;
import mcp.mobius.waila.api.IServerDataProvider;
/**
* Base implementation for {@link mcp.mobius.waila.api.IComponentProvider}
*
* @author thatsIch
* @version rv2
* @since rv2
*/
public abstract class BaseWailaDataProvider implements IComponentProvider, IServerDataProvider<TileEntity> {
@Override
public ItemStack getStack(final IDataAccessor accessor, final IPluginConfig config) {
return ItemStack.EMPTY;
}
@Override
public void appendServerData(CompoundNBT compoundNBT, ServerPlayerEntity serverPlayerEntity, World world,
TileEntity tileEntity) {
}
@Override
public void appendHead(List<ITextComponent> tooltip, IDataAccessor accessor, IPluginConfig config) {
}
@Override
public void appendBody(List<ITextComponent> tooltip, IDataAccessor accessor, IPluginConfig config) {
}
@Override
public void appendTail(List<ITextComponent> tooltip, IDataAccessor accessor, IPluginConfig config) {
}
}
@@ -1,164 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.waila;
import java.util.List;
import java.util.Optional;
import com.google.common.collect.Lists;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.world.World;
import mcp.mobius.waila.api.IComponentProvider;
import mcp.mobius.waila.api.IDataAccessor;
import mcp.mobius.waila.api.IPluginConfig;
import mcp.mobius.waila.api.IServerDataProvider;
import appeng.api.parts.IPart;
import appeng.integration.modules.waila.part.*;
/**
* Delegation provider for parts through {@link IPartWailaDataProvider}
*
* @author thatsIch
* @version rv2
* @since rv2
*/
public final class PartWailaDataProvider implements IComponentProvider, IServerDataProvider<TileEntity> {
/**
* Contains all providers
*/
private final List<IPartWailaDataProvider> providers;
/**
* Can access parts through view-hits
*/
private final PartAccessor accessor = new PartAccessor();
/**
* Traces views hit on blocks
*/
private final Tracer tracer = new Tracer();
/**
* Initializes the provider list with all wanted providers
*/
public PartWailaDataProvider() {
final IPartWailaDataProvider channel = new ChannelWailaDataProvider();
final IPartWailaDataProvider storageMonitor = new StorageMonitorWailaDataProvider();
final IPartWailaDataProvider powerState = new PowerStateWailaDataProvider();
final IPartWailaDataProvider p2pState = new P2PStateWailaDataProvider();
final IPartWailaDataProvider partStack = new PartStackWailaDataProvider();
this.providers = Lists.newArrayList(channel, storageMonitor, powerState, partStack, p2pState);
}
@Override
public ItemStack getStack(final IDataAccessor accessor, final IPluginConfig config) {
final TileEntity te = accessor.getTileEntity();
final RayTraceResult mop = accessor.getHitResult();
final Optional<IPart> maybePart = this.accessor.getMaybePart(te, mop);
if (maybePart.isPresent()) {
final IPart part = maybePart.get();
ItemStack wailaStack = ItemStack.EMPTY;
for (final IPartWailaDataProvider provider : this.providers) {
wailaStack = provider.getStack(part, config, wailaStack);
}
return wailaStack;
}
return ItemStack.EMPTY;
}
@Override
public void appendHead(List<ITextComponent> currentToolTip, final IDataAccessor accessor,
final IPluginConfig config) {
final TileEntity te = accessor.getTileEntity();
final RayTraceResult mop = accessor.getHitResult();
final Optional<IPart> maybePart = this.accessor.getMaybePart(te, mop);
if (maybePart.isPresent()) {
final IPart part = maybePart.get();
for (final IPartWailaDataProvider provider : this.providers) {
provider.appendHead(part, currentToolTip, accessor, config);
}
}
}
@Override
public void appendBody(List<ITextComponent> tooltip, final IDataAccessor accessor, final IPluginConfig config) {
final TileEntity te = accessor.getTileEntity();
final RayTraceResult mop = accessor.getHitResult();
final Optional<IPart> maybePart = this.accessor.getMaybePart(te, mop);
if (maybePart.isPresent()) {
final IPart part = maybePart.get();
for (final IPartWailaDataProvider provider : this.providers) {
provider.appendBody(part, tooltip, accessor, config);
}
}
}
@Override
public void appendTail(List<ITextComponent> tooltip, final IDataAccessor accessor, final IPluginConfig config) {
final TileEntity te = accessor.getTileEntity();
final RayTraceResult mop = accessor.getHitResult();
final Optional<IPart> maybePart = this.accessor.getMaybePart(te, mop);
if (maybePart.isPresent()) {
final IPart part = maybePart.get();
for (final IPartWailaDataProvider provider : this.providers) {
provider.appendTail(part, tooltip, accessor, config);
}
}
}
@Override
public void appendServerData(CompoundNBT tag, ServerPlayerEntity player, World world, TileEntity te) {
final RayTraceResult mop = this.tracer.retraceBlock(world, player, te.getPos());
if (mop != null) {
final Optional<IPart> maybePart = this.accessor.getMaybePart(te, mop);
if (maybePart.isPresent()) {
final IPart part = maybePart.get();
for (final IPartWailaDataProvider provider : this.providers) {
provider.appendServerData(player, part, te, tag, world, te.getPos());
}
}
}
}
}
@@ -1,104 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.waila;
import java.util.List;
import com.google.common.collect.Lists;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.world.World;
import mcp.mobius.waila.api.IComponentProvider;
import mcp.mobius.waila.api.IDataAccessor;
import mcp.mobius.waila.api.IPluginConfig;
import mcp.mobius.waila.api.IServerDataProvider;
import appeng.integration.modules.waila.tile.ChargerWailaDataProvider;
import appeng.integration.modules.waila.tile.CraftingMonitorWailaDataProvider;
import appeng.integration.modules.waila.tile.PowerStateWailaDataProvider;
import appeng.integration.modules.waila.tile.PowerStorageWailaDataProvider;
/**
* Delegation provider for tiles through
* {@link mcp.mobius.waila.api.IComponentProvider}
*
* @author thatsIch
* @version rv2
* @since rv2
*/
public final class TileWailaDataProvider implements IComponentProvider, IServerDataProvider<TileEntity> {
/**
* Contains all providers
*/
private final List<BaseWailaDataProvider> providers;
/**
* Initializes the provider list with all wanted providers
*/
public TileWailaDataProvider() {
final BaseWailaDataProvider charger = new ChargerWailaDataProvider();
final BaseWailaDataProvider energyCell = new PowerStorageWailaDataProvider();
final BaseWailaDataProvider craftingBlock = new PowerStateWailaDataProvider();
final BaseWailaDataProvider craftingMonitor = new CraftingMonitorWailaDataProvider();
this.providers = Lists.newArrayList(charger, energyCell, craftingBlock, craftingMonitor);
}
@Override
public ItemStack getStack(final IDataAccessor accessor, final IPluginConfig config) {
return ItemStack.EMPTY;
}
@Override
public void appendHead(List<ITextComponent> currentToolTip, final IDataAccessor accessor,
final IPluginConfig config) {
for (final BaseWailaDataProvider provider : this.providers) {
provider.appendHead(currentToolTip, accessor, config);
}
}
@Override
public void appendBody(List<ITextComponent> currentToolTip, final IDataAccessor accessor,
final IPluginConfig config) {
for (final BaseWailaDataProvider provider : this.providers) {
provider.appendBody(currentToolTip, accessor, config);
}
}
@Override
public void appendTail(List<ITextComponent> currentToolTip, final IDataAccessor accessor,
final IPluginConfig config) {
for (final BaseWailaDataProvider provider : this.providers) {
provider.appendTail(currentToolTip, accessor, config);
}
}
@Override
public void appendServerData(CompoundNBT tag, ServerPlayerEntity player, World world, TileEntity te) {
for (final BaseWailaDataProvider provider : this.providers) {
provider.appendServerData(tag, player, world, te);
}
}
}
@@ -1,48 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.waila;
import java.util.List;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.ITextComponent;
import mcp.mobius.waila.api.*;
import appeng.entity.EntityGrowingCrystal;
import appeng.items.misc.ItemCrystalSeed;
import appeng.tile.AEBaseTile;
@WailaPlugin
public class WailaModule implements IWailaPlugin {
public void register(final IRegistrar registrar) {
final PartWailaDataProvider partHost = new PartWailaDataProvider();
registrar.registerStackProvider(partHost, AEBaseTile.class);
registrar.registerComponentProvider(partHost, TooltipPosition.BODY, AEBaseTile.class);
registrar.registerBlockDataProvider(partHost, AEBaseTile.class);
final TileWailaDataProvider tile = new TileWailaDataProvider();
registrar.registerComponentProvider(tile, TooltipPosition.BODY, AEBaseTile.class);
registrar.registerBlockDataProvider(tile, AEBaseTile.class);
}
}
@@ -1,69 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.waila.part;
import java.util.List;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.world.World;
import mcp.mobius.waila.api.IDataAccessor;
import mcp.mobius.waila.api.IPluginConfig;
import appeng.api.parts.IPart;
/**
* Default implementation of
* {@link appeng.integration.modules.waila.part.IPartWailaDataProvider}
*
* @author thatsIch
* @version rv2
* @since rv2
*/
public abstract class BasePartWailaDataProvider implements IPartWailaDataProvider {
@Override
public ItemStack getStack(final IPart part, final IPluginConfig config, final ItemStack partStack) {
return ItemStack.EMPTY;
}
@Override
public void appendHead(final IPart part, final List<ITextComponent> tooltip, final IDataAccessor accessor,
final IPluginConfig config) {
}
@Override
public void appendBody(final IPart part, final List<ITextComponent> tooltip, final IDataAccessor accessor,
final IPluginConfig config) {
}
@Override
public void appendTail(final IPart part, final List<ITextComponent> tooltip, final IDataAccessor accessor,
final IPluginConfig config) {
}
@Override
public void appendServerData(ServerPlayerEntity player, IPart part, TileEntity te, CompoundNBT tag, World world,
BlockPos pos) {
}
}
@@ -1,145 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.waila.part;
import java.util.List;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.world.World;
import it.unimi.dsi.fastutil.objects.Object2ByteMap;
import it.unimi.dsi.fastutil.objects.Object2ByteOpenHashMap;
import mcp.mobius.waila.api.IDataAccessor;
import mcp.mobius.waila.api.IPluginConfig;
import appeng.api.parts.IPart;
import appeng.core.localization.WailaText;
import appeng.parts.networking.PartCableSmart;
import appeng.parts.networking.PartDenseCableSmart;
/**
* Channel-information provider for WAILA
*
* @author thatsIch
* @version rv2
* @since rv2
*/
public final class ChannelWailaDataProvider extends BasePartWailaDataProvider {
/**
* Channel key used for the transferred {@link net.minecraft.nbt.CompoundNBT}
*/
private static final String ID_USED_CHANNELS = "usedChannels";
/**
* Used cache for channels if the channel was not transmitted through the
* server.
* <p/>
* This is useful, when a player just started to look at a tile and thus just
* requested the new information from the server.
* <p/>
* The cache will be updated from the server.
*/
private final Object2ByteMap<IPart> cache = new Object2ByteOpenHashMap<>();
/**
* Adds the used and max channel to the tool tip
*
* @param part being looked at part
* @param tooltip current tool tip
* @param accessor wrapper for various world information
* @param config config to react to various settings
*/
@Override
public void appendBody(final IPart part, final List<ITextComponent> tooltip, final IDataAccessor accessor,
final IPluginConfig config) {
if (part instanceof PartCableSmart || part instanceof PartDenseCableSmart) {
final CompoundNBT tag = accessor.getServerData();
final byte usedChannels = this.getUsedChannels(part, tag, this.cache);
if (usedChannels >= 0) {
final byte maxChannels = (byte) ((part instanceof PartDenseCableSmart) ? 32 : 8);
final ITextComponent formattedToolTip = WailaText.Channels.textComponent(usedChannels, maxChannels);
tooltip.add(formattedToolTip);
}
}
}
/**
* Determines the source of the channel.
* <p/>
* If the client received information of the channels on the server, they are
* used, else if the cache contains a previous stored value, this will be used.
* Default value is 0.
*
* @param part part to be looked at
* @param tag tag maybe containing the channel information
* @param cache cache with previous knowledge
*
* @return used channels on the cable
*/
private byte getUsedChannels(final IPart part, final CompoundNBT tag, final Object2ByteMap<IPart> cache) {
final byte usedChannels;
if (tag.contains(ID_USED_CHANNELS)) {
usedChannels = tag.getByte(ID_USED_CHANNELS);
this.cache.put(part, usedChannels);
} else if (this.cache.containsKey(part)) {
usedChannels = this.cache.get(part);
} else {
usedChannels = -1;
}
return usedChannels;
}
/**
* Called on server to transfer information from server to client.
* <p/>
* If the part is a cable, it writes the channel information in the {@code #tag}
* using the {@code ID_USED_CHANNELS} key.
*
* @param player player looking at the part
* @param part part being looked at
* @param te host of the part
* @param tag transferred tag which is send to the client
* @param world world of the part
* @param pos pos of the part
*/
@Override
public void appendServerData(ServerPlayerEntity player, IPart part, TileEntity te, CompoundNBT tag, World world,
BlockPos pos) {
if (part instanceof PartCableSmart || part instanceof PartDenseCableSmart) {
final CompoundNBT tempTag = new CompoundNBT();
part.writeToNBT(tempTag);
if (tempTag.contains(ID_USED_CHANNELS)) {
final byte usedChannels = tempTag.getByte(ID_USED_CHANNELS);
tag.putByte(ID_USED_CHANNELS, usedChannels);
}
}
}
}
@@ -1,56 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.waila.part;
import java.util.List;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.world.World;
import mcp.mobius.waila.api.IDataAccessor;
import mcp.mobius.waila.api.IPluginConfig;
import appeng.api.parts.IPart;
/**
* An abstraction layer of the
* {@link appeng.integration.modules.waila.part.IPartWailaDataProvider} for
* {@link appeng.api.parts.IPart}.
*
* @author thatsIch
* @version rv2
* @since rv2
*/
public interface IPartWailaDataProvider {
ItemStack getStack(IPart part, IPluginConfig config, ItemStack partStack);
void appendHead(IPart part, List<ITextComponent> tooltip, IDataAccessor accessor, IPluginConfig config);
void appendBody(IPart part, List<ITextComponent> tooltip, IDataAccessor accessor, IPluginConfig config);
void appendTail(IPart part, List<ITextComponent> tooltip, IDataAccessor accessor, IPluginConfig config);
void appendServerData(ServerPlayerEntity player, IPart part, TileEntity te, CompoundNBT tag, World world,
BlockPos pos);
}
@@ -1,145 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.waila.part;
import java.util.List;
import com.google.common.collect.Iterators;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.world.World;
import mcp.mobius.waila.api.IDataAccessor;
import mcp.mobius.waila.api.IPluginConfig;
import appeng.api.parts.IPart;
import appeng.core.localization.WailaText;
import appeng.me.GridAccessException;
import appeng.parts.p2p.PartP2PTunnel;
import appeng.util.Platform;
/**
* Provides information about a P2P tunnel to WAILA.
*/
public final class P2PStateWailaDataProvider extends BasePartWailaDataProvider {
private static final int STATE_UNLINKED = 0;
private static final int STATE_OUTPUT = 1;
private static final int STATE_INPUT = 2;
public static final String TAG_P2P_STATE = "p2p_state";
public static final String TAG_P2P_FREQUENCY = "p2p_frequency";
/**
* Adds state to the tooltip
*
* @param part part with state
* @param tooltip to be added to tooltip
* @param accessor wrapper for various information
* @param config config settings
*/
@Override
public void appendBody(final IPart part, final List<ITextComponent> tooltip, final IDataAccessor accessor,
final IPluginConfig config) {
if (part instanceof PartP2PTunnel) {
CompoundNBT nbtData = accessor.getServerData();
if (nbtData.contains(TAG_P2P_STATE)) {
int[] stateArr = nbtData.getIntArray(TAG_P2P_STATE);
if (stateArr.length == 2) {
int state = stateArr[0];
int outputs = stateArr[1];
switch (state) {
case STATE_UNLINKED:
tooltip.add(WailaText.P2PUnlinked.textComponent());
break;
case STATE_OUTPUT:
tooltip.add(WailaText.P2POutput.textComponent());
break;
case STATE_INPUT:
tooltip.add(getOutputText(outputs));
break;
}
}
final short freq = nbtData.getShort(TAG_P2P_FREQUENCY);
final String freqTooltip = Platform.p2p().toHexString(freq);
tooltip.add(new TranslationTextComponent("gui.tooltips.appliedenergistics2.P2PFrequency", freqTooltip));
}
}
}
@Override
public void appendServerData(ServerPlayerEntity player, IPart part, TileEntity te, CompoundNBT tag, World world,
BlockPos pos) {
if (part instanceof PartP2PTunnel) {
final PartP2PTunnel<?> tunnel = (PartP2PTunnel<?>) part;
if (!tunnel.isPowered()) {
return;
}
// Frquency
final short frequency = tunnel.getFrequency();
tag.putShort(TAG_P2P_FREQUENCY, frequency);
// The default state
int state = STATE_UNLINKED;
int outputCount = 0;
if (!tunnel.isOutput()) {
outputCount = getOutputCount(tunnel);
if (outputCount > 0) {
// Only set it to INPUT if we know there are any outputs
state = STATE_INPUT;
}
} else {
PartP2PTunnel<?> input = tunnel.getInput();
if (input != null) {
state = STATE_OUTPUT;
}
}
tag.putIntArray(TAG_P2P_STATE, new int[] { state, outputCount });
}
}
private static int getOutputCount(PartP2PTunnel<?> tunnel) {
try {
return Iterators.size(tunnel.getOutputs().iterator());
} catch (GridAccessException e) {
// Well... unknown size it is!
return 0;
}
}
private static ITextComponent getOutputText(int outputs) {
if (outputs <= 1) {
return WailaText.P2PInputOneOutput.textComponent();
} else {
return WailaText.P2PInputManyOutputs.textComponent(outputs);
}
}
}
@@ -1,66 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.waila.part;
import java.util.Optional;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d;
import appeng.api.parts.IPart;
import appeng.api.parts.IPartHost;
import appeng.api.parts.SelectedPart;
/**
* Accessor to access specific parts for WAILA
*
* @author thatsIch
* @version rv2
* @since rv2
*/
public final class PartAccessor {
/**
* Hits a {@link IPartHost} with {@link BlockPos}.
* <p/>
* You can derive the looked at {@link IPart} by doing that. If a facade is
* being looked at, it is defined as being absent.
*
* @param te being looked at {@link TileEntity}
* @param rtr type of ray-trace
*
* @return maybe the looked at {@link IPart}
*/
public Optional<IPart> getMaybePart(final TileEntity te, final RayTraceResult rtr) {
if (te instanceof IPartHost && rtr instanceof BlockRayTraceResult) {
BlockPos pos = ((BlockRayTraceResult) rtr).getPos();
final Vec3d position = rtr.getHitVec().add(-pos.getX(), -pos.getY(), -pos.getZ());
final IPartHost host = (IPartHost) te;
final SelectedPart sp = host.selectPart(position);
if (sp.part != null) {
return Optional.of(sp.part);
}
}
return Optional.empty();
}
}
@@ -1,43 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.waila.part;
import net.minecraft.item.ItemStack;
import mcp.mobius.waila.api.IPluginConfig;
import appeng.api.parts.IPart;
import appeng.api.parts.PartItemStack;
/**
* Part ItemStack provider for WAILA
*
* @author TheJulianJES
* @version rv2
* @since rv2
*/
public class PartStackWailaDataProvider extends BasePartWailaDataProvider {
@Override
public ItemStack getStack(final IPart part, final IPluginConfig config, ItemStack partStack) {
partStack = part.getItemStack(PartItemStack.PICK);
return partStack;
}
}
@@ -1,76 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.waila.part;
import java.util.List;
import net.minecraft.util.text.ITextComponent;
import mcp.mobius.waila.api.IDataAccessor;
import mcp.mobius.waila.api.IPluginConfig;
import appeng.api.implementations.IPowerChannelState;
import appeng.api.parts.IPart;
import appeng.core.localization.WailaText;
/**
* Power state provider for WAILA
*
* @author thatsIch
* @version rv2
* @since rv2
*/
public final class PowerStateWailaDataProvider extends BasePartWailaDataProvider {
/**
* Adds state to the tooltip
*
* @param part part with state
* @param tooltip to be added to tooltip
* @param accessor wrapper for various information
* @param config config settings
*/
@Override
public void appendBody(final IPart part, final List<ITextComponent> tooltip, final IDataAccessor accessor,
final IPluginConfig config) {
if (part instanceof IPowerChannelState) {
final IPowerChannelState state = (IPowerChannelState) part;
tooltip.add(this.getToolTip(state.isActive(), state.isPowered()));
}
}
/**
* Gets the corresponding tool tip for different values of {@code #isActive} and
* {@code #isPowered}
*
* @param isActive if part is active
* @param isPowered if part is powered
*
* @return tooltip of the state
*/
private ITextComponent getToolTip(final boolean isActive, final boolean isPowered) {
if (isActive && isPowered) {
return WailaText.DeviceOnline.textComponent();
} else if (isPowered) {
return WailaText.DeviceMissingChannel.textComponent();
} else {
return WailaText.DeviceOffline.textComponent();
}
}
}
@@ -1,75 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.waila.part;
import java.util.List;
import net.minecraft.util.text.ITextComponent;
import mcp.mobius.waila.api.IDataAccessor;
import mcp.mobius.waila.api.IPluginConfig;
import appeng.api.implementations.parts.IPartStorageMonitor;
import appeng.api.parts.IPart;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IAEStack;
import appeng.core.localization.WailaText;
/**
* Storage monitor provider for WAILA
*
* @author thatsIch
* @version rv2
* @since rv2
*/
public final class StorageMonitorWailaDataProvider extends BasePartWailaDataProvider {
/**
* Displays the stack if present and if the monitor is locked. Can handle fluids
* and items.
*
* @param part maybe storage monitor
* @param tooltip to be written to tooltip
* @param accessor information wrapper
* @param config config option
*/
@Override
public void appendBody(final IPart part, final List<ITextComponent> tooltip, final IDataAccessor accessor,
final IPluginConfig config) {
if (part instanceof IPartStorageMonitor) {
final IPartStorageMonitor monitor = (IPartStorageMonitor) part;
final IAEStack<?> displayed = monitor.getDisplayed();
final boolean isLocked = monitor.isLocked();
// TODO: generalize
if (displayed instanceof IAEItemStack) {
final IAEItemStack ais = (IAEItemStack) displayed;
tooltip.add(WailaText.Showing.textComponent().appendText(": ")
.appendSibling(ais.asItemStackRepresentation().getDisplayName()));
} else if (displayed instanceof IAEFluidStack) {
final IAEFluidStack ais = (IAEFluidStack) displayed;
tooltip.add(WailaText.Showing.textComponent().appendText(": ")
.appendSibling(ais.getFluid().getAttributes().getDisplayName(ais.getFluidStack())));
}
tooltip.add((isLocked) ? WailaText.Locked.textComponent() : WailaText.Unlocked.textComponent());
}
}
}
@@ -1,89 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.waila.part;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
/**
* Tracer for players hitting blocks
*
* @author thatsIch
* @version rv2
* @since rv2
*/
public final class Tracer {
/**
* Trace view of players to blocks. Ignore all which are out of reach.
*
* @param world word of block
* @param player player viewing block
* @param pos pos of block
*
* @return trace movement. Can be null
*/
public RayTraceResult retraceBlock(final World world, final PlayerEntity player, BlockPos pos) {
BlockState blockState = world.getBlockState(pos);
final Vec3d headVec = this.getCorrectedHeadVec(player);
final Vec3d lookVec = player.getLook(1.0F);
final double reach = this.getBlockReachDistance_server(player);
final Vec3d endVec = headVec.add(lookVec.x * reach, lookVec.y * reach, lookVec.z * reach);
return blockState.getCollisionShape(world, pos).rayTrace(headVec, endVec, pos);
}
/**
* Gets the view point of a player
*
* @param player player with head
*
* @return view point of player
*/
private Vec3d getCorrectedHeadVec(final PlayerEntity player) {
double x = player.getPosX();
double y = player.getPosY();
double z = player.getPosZ();
if (player.world.isRemote) {
// compatibility with eye height changing mods
y += player.getEyeHeight() - player.getEyeHeight();
} else {
y += player.getEyeHeight();
if (player instanceof ServerPlayerEntity && player.isSneaking()) {
y -= 0.08;
}
}
return new Vec3d(x, y, z);
}
/**
* @param player multi-player player
*
* @return block reach distance of player
*/
private double getBlockReachDistance_server(final PlayerEntity player) {
return player.getAttribute(net.minecraft.entity.player.PlayerEntity.REACH_DISTANCE).getValue();
}
}
@@ -1,71 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.waila.tile;
import java.util.List;
import javax.annotation.Nonnull;
import net.minecraft.client.Minecraft;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.text.ITextComponent;
import net.minecraftforge.items.IItemHandler;
import mcp.mobius.waila.api.IDataAccessor;
import mcp.mobius.waila.api.IPluginConfig;
import appeng.core.localization.WailaText;
import appeng.integration.modules.waila.BaseWailaDataProvider;
import appeng.tile.misc.TileCharger;
/**
* Charger provider for WAILA
*
* @author thatsIch
* @version rv2
* @since rv2
*/
public final class ChargerWailaDataProvider extends BaseWailaDataProvider {
@Override
public void appendBody(List<ITextComponent> tooltip, IDataAccessor accessor, IPluginConfig config) {
final TileEntity te = accessor.getTileEntity();
if (te instanceof TileCharger) {
final TileCharger charger = (TileCharger) te;
final IItemHandler chargerInventory = charger.getInternalInventory();
final ItemStack chargingItem = chargerInventory.getStackInSlot(0);
if (!chargingItem.isEmpty()) {
final ITextComponent currentInventory = chargingItem.getDisplayName();
final PlayerEntity player = accessor.getPlayer();
tooltip.add(WailaText.Contains.textComponent().appendText(": ").appendSibling(currentInventory));
ITooltipFlag.TooltipFlags tooltipFlag = Minecraft.getInstance().gameSettings.advancedItemTooltips
? ITooltipFlag.TooltipFlags.ADVANCED
: ITooltipFlag.TooltipFlags.NORMAL;
chargingItem.getItem().addInformation(chargingItem, player.world, tooltip, tooltipFlag);
}
}
}
}
@@ -1,58 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.waila.tile;
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.text.ITextComponent;
import mcp.mobius.waila.api.IDataAccessor;
import mcp.mobius.waila.api.IPluginConfig;
import appeng.api.storage.data.IAEItemStack;
import appeng.core.localization.WailaText;
import appeng.integration.modules.waila.BaseWailaDataProvider;
import appeng.tile.crafting.TileCraftingMonitorTile;
/**
* Crafting-monitor provider for WAILA
*
* @author thatsIch
* @version rv2
* @since rv2
*/
public final class CraftingMonitorWailaDataProvider extends BaseWailaDataProvider {
@Override
public void appendBody(List<ITextComponent> tooltip, IDataAccessor accessor, IPluginConfig config) {
final TileEntity te = accessor.getTileEntity();
if (te instanceof TileCraftingMonitorTile) {
final TileCraftingMonitorTile monitor = (TileCraftingMonitorTile) te;
final IAEItemStack displayStack = monitor.getJobProgress();
if (displayStack != null) {
final ITextComponent currentCrafting = displayStack.asItemStackRepresentation().getDisplayName();
tooltip.add(WailaText.Crafting.textComponent().appendText(": ").appendSibling(currentCrafting));
}
}
}
}
@@ -1,63 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.waila.tile;
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.text.ITextComponent;
import mcp.mobius.waila.api.IDataAccessor;
import mcp.mobius.waila.api.IPluginConfig;
import appeng.api.implementations.IPowerChannelState;
import appeng.core.localization.WailaText;
import appeng.integration.modules.waila.BaseWailaDataProvider;
/**
* Power state provider for WAILA
*
* @author thatsIch
* @version rv2
* @since rv2
*/
public final class PowerStateWailaDataProvider extends BaseWailaDataProvider {
@Override
public void appendBody(List<ITextComponent> tooltip, IDataAccessor accessor, IPluginConfig config) {
final TileEntity te = accessor.getTileEntity();
if (te instanceof IPowerChannelState) {
final IPowerChannelState state = (IPowerChannelState) te;
final boolean isActive = state.isActive();
final boolean isPowered = state.isPowered();
if (isActive && isPowered) {
tooltip.add(WailaText.DeviceOnline.textComponent());
} else if (isPowered) {
tooltip.add(WailaText.DeviceMissingChannel.textComponent());
} else {
tooltip.add(WailaText.DeviceOffline.textComponent());
}
}
}
}
@@ -1,142 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.waila.tile;
import java.util.List;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.world.World;
import it.unimi.dsi.fastutil.objects.Object2LongMap;
import it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap;
import mcp.mobius.waila.api.IDataAccessor;
import mcp.mobius.waila.api.IPluginConfig;
import appeng.api.networking.energy.IAEPowerStorage;
import appeng.core.localization.WailaText;
import appeng.integration.modules.waila.BaseWailaDataProvider;
import appeng.util.Platform;
/**
* Power storage provider for WAILA
*
* @author thatsIch
* @version rv2
* @since rv2
*/
public final class PowerStorageWailaDataProvider extends BaseWailaDataProvider {
/**
* Power key used for the transferred {@link net.minecraft.nbt.CompoundNBT}
*/
private static final String ID_CURRENT_POWER = "currentPower";
/**
* Used cache for power if the power was not transmitted through the server.
* <p/>
* This is useful, when a player just started to look at a tile and thus just
* requested the new information from the server.
* <p/>
* The cache will be updated from the server.
*/
private final Object2LongMap<TileEntity> cache = new Object2LongOpenHashMap<>();
@Override
public void appendBody(List<ITextComponent> tooltip, IDataAccessor accessor, IPluginConfig config) {
// Removes RF tooltip on WAILA 1.5.9+
// FIXME ( (ITaggedList<String, String>) tooltip ).removeEntries(
// "RFEnergyStorage" );
final TileEntity te = accessor.getTileEntity();
if (te instanceof IAEPowerStorage) {
final IAEPowerStorage storage = (IAEPowerStorage) te;
final double maxPower = storage.getAEMaxPower();
if (maxPower > 0) {
final CompoundNBT tag = accessor.getServerData();
final long internalCurrentPower = this.getInternalCurrentPower(tag, te);
if (internalCurrentPower >= 0) {
final long internalMaxPower = (long) (100 * maxPower);
final String formatCurrentPower = Platform.formatPowerLong(internalCurrentPower, false);
final String formatMaxPower = Platform.formatPowerLong(internalMaxPower, false);
tooltip.add(WailaText.Contains.textComponent()
.appendText(": " + formatCurrentPower + " / " + formatMaxPower));
}
}
}
}
/**
* Called on server to transfer information from server to client.
* <p/>
* If the {@link net.minecraft.tileentity.TileEntity} is a
* {@link appeng.api.networking.energy.IAEPowerStorage}, it writes the power
* information to the {@code #tag} using the {@code #ID_CURRENT_POWER} key.
*
* @param serverPlayerEntity player looking at the power storage
* @param te power storage
* @param tag transferred tag which is send to the client
* @param world world of the power storage
*/
@Override
public void appendServerData(CompoundNBT tag, ServerPlayerEntity serverPlayerEntity, World world, TileEntity te) {
if (te instanceof IAEPowerStorage) {
final IAEPowerStorage storage = (IAEPowerStorage) te;
if (storage.getAEMaxPower() > 0) {
final long internalCurrentPower = (long) (100 * storage.getAECurrentPower());
tag.putLong(ID_CURRENT_POWER, internalCurrentPower);
}
}
}
/**
* Determines the current power.
* <p/>
* If the client received power information on the server, they are used, else
* if the cache contains a previous stored value, this will be used. Default
* value is 0.
*
* @param te te to be looked at
* @param tag tag maybe containing the channel information
*
* @return used channels on the cable
*/
private long getInternalCurrentPower(final CompoundNBT tag, final TileEntity te) {
final long internalCurrentPower;
if (tag.contains(ID_CURRENT_POWER)) {
internalCurrentPower = tag.getLong(ID_CURRENT_POWER);
this.cache.put(te, internalCurrentPower);
} else if (this.cache.containsKey(te)) {
internalCurrentPower = this.cache.get(te);
} else {
internalCurrentPower = -1;
}
return internalCurrentPower;
}
}