reformatted all src files (#141)
This commit is contained in:
+27
-36
@@ -19,54 +19,45 @@
|
||||
package appeng.integration.modules.theoneprobe.part;
|
||||
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.integration.modules.theoneprobe.TheOneProbeText;
|
||||
import appeng.parts.networking.PartCableSmart;
|
||||
import appeng.parts.networking.PartDenseCableSmart;
|
||||
import mcjty.theoneprobe.api.IProbeHitData;
|
||||
import mcjty.theoneprobe.api.IProbeInfo;
|
||||
import mcjty.theoneprobe.api.ProbeMode;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import mcjty.theoneprobe.api.IProbeHitData;
|
||||
import mcjty.theoneprobe.api.IProbeInfo;
|
||||
import mcjty.theoneprobe.api.ProbeMode;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.integration.modules.theoneprobe.TheOneProbeText;
|
||||
import appeng.parts.networking.PartCableSmart;
|
||||
import appeng.parts.networking.PartDenseCableSmart;
|
||||
public class ChannelInfoProvider implements IPartProbInfoProvider {
|
||||
|
||||
@Override
|
||||
public void addProbeInfo(IPart part, ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data) {
|
||||
if (!AEConfig.instance().isFeatureEnabled(AEFeature.CHANNELS)) {
|
||||
return;
|
||||
}
|
||||
if (part instanceof PartDenseCableSmart || part instanceof PartCableSmart) {
|
||||
final int usedChannels;
|
||||
final int maxChannels = (part instanceof PartDenseCableSmart) ? 32 : 8;
|
||||
|
||||
public class ChannelInfoProvider implements IPartProbInfoProvider
|
||||
{
|
||||
if (part.getGridNode().isActive()) {
|
||||
final NBTTagCompound tmp = new NBTTagCompound();
|
||||
part.writeToNBT(tmp);
|
||||
usedChannels = tmp.getByte("usedChannels");
|
||||
} else {
|
||||
usedChannels = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addProbeInfo( IPart part, ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data )
|
||||
{
|
||||
if( !AEConfig.instance().isFeatureEnabled( AEFeature.CHANNELS ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
if( part instanceof PartDenseCableSmart || part instanceof PartCableSmart )
|
||||
{
|
||||
final int usedChannels;
|
||||
final int maxChannels = ( part instanceof PartDenseCableSmart ) ? 32 : 8;
|
||||
final String formattedChannelString = String.format(TheOneProbeText.CHANNELS.getLocal(), usedChannels, maxChannels);
|
||||
|
||||
if( part.getGridNode().isActive() )
|
||||
{
|
||||
final NBTTagCompound tmp = new NBTTagCompound();
|
||||
part.writeToNBT( tmp );
|
||||
usedChannels = tmp.getByte( "usedChannels" );
|
||||
}
|
||||
else
|
||||
{
|
||||
usedChannels = 0;
|
||||
}
|
||||
probeInfo.text(formattedChannelString);
|
||||
}
|
||||
|
||||
final String formattedChannelString = String.format( TheOneProbeText.CHANNELS.getLocal(), usedChannels, maxChannels );
|
||||
|
||||
probeInfo.text( formattedChannelString );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+9
-13
@@ -19,27 +19,23 @@
|
||||
package appeng.integration.modules.theoneprobe.part;
|
||||
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import mcjty.theoneprobe.api.IProbeHitData;
|
||||
import mcjty.theoneprobe.api.IProbeInfo;
|
||||
import mcjty.theoneprobe.api.IProbeInfoProvider;
|
||||
import mcjty.theoneprobe.api.ProbeMode;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
|
||||
/**
|
||||
* Similar to {@link IProbeInfoProvider}, but already providing the {@link IPart} being looked at.
|
||||
*
|
||||
*/
|
||||
public interface IPartProbInfoProvider
|
||||
{
|
||||
public interface IPartProbInfoProvider {
|
||||
|
||||
/**
|
||||
* @see IProbeInfoProvider#addProbeInfo(ProbeMode, IProbeInfo, EntityPlayer, World, IBlockState, IProbeHitData)
|
||||
*/
|
||||
void addProbeInfo( IPart part, ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data );
|
||||
/**
|
||||
* @see IProbeInfoProvider#addProbeInfo(ProbeMode, IProbeInfo, EntityPlayer, World, IBlockState, IProbeHitData)
|
||||
*/
|
||||
void addProbeInfo(IPart part, ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data);
|
||||
}
|
||||
|
||||
+78
-107
@@ -19,131 +19,102 @@
|
||||
package appeng.integration.modules.theoneprobe.part;
|
||||
|
||||
|
||||
import com.google.common.collect.Iterators;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import mcjty.theoneprobe.api.IProbeHitData;
|
||||
import mcjty.theoneprobe.api.IProbeInfo;
|
||||
import mcjty.theoneprobe.api.ProbeMode;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.integration.modules.theoneprobe.TheOneProbeText;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.parts.p2p.PartP2PTunnel;
|
||||
import appeng.util.Platform;
|
||||
import com.google.common.collect.Iterators;
|
||||
import mcjty.theoneprobe.api.IProbeHitData;
|
||||
import mcjty.theoneprobe.api.IProbeInfo;
|
||||
import mcjty.theoneprobe.api.ProbeMode;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
|
||||
public class P2PStateInfoProvider implements IPartProbInfoProvider
|
||||
{
|
||||
public class P2PStateInfoProvider implements IPartProbInfoProvider {
|
||||
|
||||
private static final int STATE_UNLINKED = 0;
|
||||
private static final int STATE_OUTPUT = 1;
|
||||
private static final int STATE_INPUT = 2;
|
||||
private static final int STATE_UNLINKED = 0;
|
||||
private static final int STATE_OUTPUT = 1;
|
||||
private static final int STATE_INPUT = 2;
|
||||
|
||||
@Override
|
||||
public void addProbeInfo( IPart part, ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data )
|
||||
{
|
||||
if( part instanceof PartP2PTunnel )
|
||||
{
|
||||
final PartP2PTunnel tunnel = (PartP2PTunnel) part;
|
||||
@Override
|
||||
public void addProbeInfo(IPart part, ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data) {
|
||||
if (part instanceof PartP2PTunnel) {
|
||||
final PartP2PTunnel tunnel = (PartP2PTunnel) part;
|
||||
|
||||
if( !tunnel.isPowered() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!tunnel.isPowered()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// The default state
|
||||
int state = STATE_UNLINKED;
|
||||
int outputCount = getOutputCount( tunnel );
|
||||
int inputCount = getInputCount( tunnel );
|
||||
// The default state
|
||||
int state = STATE_UNLINKED;
|
||||
int outputCount = getOutputCount(tunnel);
|
||||
int inputCount = getInputCount(tunnel);
|
||||
|
||||
if( !tunnel.isOutput() )
|
||||
{
|
||||
if( outputCount > 0 )
|
||||
{
|
||||
// Only set it to INPUT if we know there are any outputs
|
||||
state = STATE_INPUT;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( inputCount > 0 )
|
||||
{
|
||||
state = STATE_OUTPUT;
|
||||
}
|
||||
}
|
||||
if (!tunnel.isOutput()) {
|
||||
if (outputCount > 0) {
|
||||
// Only set it to INPUT if we know there are any outputs
|
||||
state = STATE_INPUT;
|
||||
}
|
||||
} else {
|
||||
if (inputCount > 0) {
|
||||
state = STATE_OUTPUT;
|
||||
}
|
||||
}
|
||||
|
||||
switch( state )
|
||||
{
|
||||
case STATE_UNLINKED:
|
||||
probeInfo.text( TheOneProbeText.P2P_UNLINKED.getLocal() );
|
||||
break;
|
||||
case STATE_OUTPUT:
|
||||
probeInfo.text( getInputText( inputCount ) );
|
||||
break;
|
||||
case STATE_INPUT:
|
||||
probeInfo.text( getOutputText( outputCount ) );
|
||||
break;
|
||||
}
|
||||
switch (state) {
|
||||
case STATE_UNLINKED:
|
||||
probeInfo.text(TheOneProbeText.P2P_UNLINKED.getLocal());
|
||||
break;
|
||||
case STATE_OUTPUT:
|
||||
probeInfo.text(getInputText(inputCount));
|
||||
break;
|
||||
case STATE_INPUT:
|
||||
probeInfo.text(getOutputText(outputCount));
|
||||
break;
|
||||
}
|
||||
|
||||
final short freq = tunnel.getFrequency();
|
||||
final String freqTooltip = Platform.p2p().toHexString( freq );
|
||||
final short freq = tunnel.getFrequency();
|
||||
final String freqTooltip = Platform.p2p().toHexString(freq);
|
||||
|
||||
probeInfo.text( freqTooltip );
|
||||
}
|
||||
}
|
||||
probeInfo.text(freqTooltip);
|
||||
}
|
||||
}
|
||||
|
||||
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 int getOutputCount(PartP2PTunnel tunnel) {
|
||||
try {
|
||||
return Iterators.size(tunnel.getOutputs().iterator());
|
||||
} catch (GridAccessException e) {
|
||||
// Well... unknown size it is!
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private static int getInputCount( PartP2PTunnel tunnel )
|
||||
{
|
||||
try
|
||||
{
|
||||
return Iterators.size( tunnel.getInputs().iterator() );
|
||||
}
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// Well... unknown size it is!
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
private static int getInputCount(PartP2PTunnel tunnel) {
|
||||
try {
|
||||
return Iterators.size(tunnel.getInputs().iterator());
|
||||
} catch (GridAccessException e) {
|
||||
// Well... unknown size it is!
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private static String getOutputText( int outputs )
|
||||
{
|
||||
if( outputs <= 1 )
|
||||
{
|
||||
return TheOneProbeText.P2P_INPUT_ONE_OUTPUT.getLocal();
|
||||
}
|
||||
else
|
||||
{
|
||||
return String.format( TheOneProbeText.P2P_INPUT_MANY_OUTPUTS.getLocal(), outputs );
|
||||
}
|
||||
}
|
||||
private static String getOutputText(int outputs) {
|
||||
if (outputs <= 1) {
|
||||
return TheOneProbeText.P2P_INPUT_ONE_OUTPUT.getLocal();
|
||||
} else {
|
||||
return String.format(TheOneProbeText.P2P_INPUT_MANY_OUTPUTS.getLocal(), outputs);
|
||||
}
|
||||
}
|
||||
|
||||
private static String getInputText( int inputs )
|
||||
{
|
||||
if( inputs <= 1 )
|
||||
{
|
||||
return TheOneProbeText.P2P_OUTPUT_ONE_INPUT.getLocal();
|
||||
}
|
||||
else
|
||||
{
|
||||
return String.format( TheOneProbeText.P2P_OUTPUT_MANY_INPUTS.getLocal(), inputs );
|
||||
}
|
||||
}
|
||||
private static String getInputText(int inputs) {
|
||||
if (inputs <= 1) {
|
||||
return TheOneProbeText.P2P_OUTPUT_ONE_INPUT.getLocal();
|
||||
} else {
|
||||
return String.format(TheOneProbeText.P2P_OUTPUT_MANY_INPUTS.getLocal(), inputs);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,37 +19,31 @@
|
||||
package appeng.integration.modules.theoneprobe.part;
|
||||
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.parts.IPartHost;
|
||||
import appeng.api.parts.SelectedPart;
|
||||
import mcjty.theoneprobe.api.IProbeHitData;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
import mcjty.theoneprobe.api.IProbeHitData;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.parts.IPartHost;
|
||||
import appeng.api.parts.SelectedPart;
|
||||
import java.util.Optional;
|
||||
|
||||
|
||||
public final class PartAccessor
|
||||
{
|
||||
public final class PartAccessor {
|
||||
|
||||
public Optional<IPart> getMaybePart( final TileEntity te, final IProbeHitData data )
|
||||
{
|
||||
if( te instanceof IPartHost )
|
||||
{
|
||||
BlockPos pos = data.getPos();
|
||||
final Vec3d position = data.getHitVec().addVector( -pos.getX(), -pos.getY(), -pos.getZ() );
|
||||
final IPartHost host = (IPartHost) te;
|
||||
final SelectedPart sp = host.selectPart( position );
|
||||
public Optional<IPart> getMaybePart(final TileEntity te, final IProbeHitData data) {
|
||||
if (te instanceof IPartHost) {
|
||||
BlockPos pos = data.getPos();
|
||||
final Vec3d position = data.getHitVec().addVector(-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 );
|
||||
}
|
||||
}
|
||||
if (sp.part != null) {
|
||||
return Optional.of(sp.part);
|
||||
}
|
||||
}
|
||||
|
||||
return Optional.empty();
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
+26
-37
@@ -19,53 +19,42 @@
|
||||
package appeng.integration.modules.theoneprobe.part;
|
||||
|
||||
|
||||
import appeng.api.implementations.IPowerChannelState;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.integration.modules.theoneprobe.TheOneProbeText;
|
||||
import mcjty.theoneprobe.api.IProbeHitData;
|
||||
import mcjty.theoneprobe.api.IProbeInfo;
|
||||
import mcjty.theoneprobe.api.ProbeMode;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import mcjty.theoneprobe.api.IProbeHitData;
|
||||
import mcjty.theoneprobe.api.IProbeInfo;
|
||||
import mcjty.theoneprobe.api.ProbeMode;
|
||||
|
||||
import appeng.api.implementations.IPowerChannelState;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.integration.modules.theoneprobe.TheOneProbeText;
|
||||
public class PowerStateInfoProvider implements IPartProbInfoProvider {
|
||||
|
||||
@Override
|
||||
public void addProbeInfo(IPart part, ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data) {
|
||||
if (part instanceof IPowerChannelState) {
|
||||
final IPowerChannelState state = (IPowerChannelState) part;
|
||||
final String tooltip = this.getToolTip(state.isActive(), state.isPowered());
|
||||
|
||||
public class PowerStateInfoProvider implements IPartProbInfoProvider
|
||||
{
|
||||
probeInfo.text(tooltip);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addProbeInfo( IPart part, ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data )
|
||||
{
|
||||
if( part instanceof IPowerChannelState )
|
||||
{
|
||||
final IPowerChannelState state = (IPowerChannelState) part;
|
||||
final String tooltip = this.getToolTip( state.isActive(), state.isPowered() );
|
||||
}
|
||||
|
||||
probeInfo.text( tooltip );
|
||||
}
|
||||
private String getToolTip(final boolean isActive, final boolean isPowered) {
|
||||
final String result;
|
||||
|
||||
}
|
||||
if (isActive && isPowered) {
|
||||
result = TheOneProbeText.DEVICE_ONLINE.getLocal();
|
||||
} else if (isPowered) {
|
||||
result = TheOneProbeText.DEVICE_MISSING_CHANNEL.getLocal();
|
||||
} else {
|
||||
result = TheOneProbeText.DEVICE_OFFLINE.getLocal();
|
||||
}
|
||||
|
||||
private String getToolTip( final boolean isActive, final boolean isPowered )
|
||||
{
|
||||
final String result;
|
||||
|
||||
if( isActive && isPowered )
|
||||
{
|
||||
result = TheOneProbeText.DEVICE_ONLINE.getLocal();
|
||||
}
|
||||
else if( isPowered )
|
||||
{
|
||||
result = TheOneProbeText.DEVICE_MISSING_CHANNEL.getLocal();
|
||||
}
|
||||
else
|
||||
{
|
||||
result = TheOneProbeText.DEVICE_OFFLINE.getLocal();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+24
-32
@@ -19,49 +19,41 @@
|
||||
package appeng.integration.modules.theoneprobe.part;
|
||||
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import mcjty.theoneprobe.api.IProbeHitData;
|
||||
import mcjty.theoneprobe.api.IProbeInfo;
|
||||
import mcjty.theoneprobe.api.ProbeMode;
|
||||
|
||||
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.integration.modules.theoneprobe.TheOneProbeText;
|
||||
import mcjty.theoneprobe.api.IProbeHitData;
|
||||
import mcjty.theoneprobe.api.IProbeInfo;
|
||||
import mcjty.theoneprobe.api.ProbeMode;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
|
||||
public class StorageMonitorInfoProvider implements IPartProbInfoProvider
|
||||
{
|
||||
public class StorageMonitorInfoProvider implements IPartProbInfoProvider {
|
||||
|
||||
@Override
|
||||
public void addProbeInfo( IPart part, ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data )
|
||||
{
|
||||
if( part instanceof IPartStorageMonitor )
|
||||
{
|
||||
final IPartStorageMonitor monitor = (IPartStorageMonitor) part;
|
||||
@Override
|
||||
public void addProbeInfo(IPart part, ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data) {
|
||||
if (part instanceof IPartStorageMonitor) {
|
||||
final IPartStorageMonitor monitor = (IPartStorageMonitor) part;
|
||||
|
||||
final IAEStack<?> displayed = monitor.getDisplayed();
|
||||
final boolean isLocked = monitor.isLocked();
|
||||
final IAEStack<?> displayed = monitor.getDisplayed();
|
||||
final boolean isLocked = monitor.isLocked();
|
||||
|
||||
// TODO: generalize
|
||||
if( displayed instanceof IAEItemStack )
|
||||
{
|
||||
final IAEItemStack ais = (IAEItemStack) displayed;
|
||||
probeInfo.text( TheOneProbeText.SHOWING.getLocal() + ": " + ais.asItemStackRepresentation().getDisplayName() );
|
||||
}
|
||||
else if( displayed instanceof IAEFluidStack )
|
||||
{
|
||||
final IAEFluidStack ais = (IAEFluidStack) displayed;
|
||||
probeInfo.text( TheOneProbeText.SHOWING.getLocal() + ": " + ais.getFluid().getLocalizedName( ais.getFluidStack() ) );
|
||||
}
|
||||
// TODO: generalize
|
||||
if (displayed instanceof IAEItemStack) {
|
||||
final IAEItemStack ais = (IAEItemStack) displayed;
|
||||
probeInfo.text(TheOneProbeText.SHOWING.getLocal() + ": " + ais.asItemStackRepresentation().getDisplayName());
|
||||
} else if (displayed instanceof IAEFluidStack) {
|
||||
final IAEFluidStack ais = (IAEFluidStack) displayed;
|
||||
probeInfo.text(TheOneProbeText.SHOWING.getLocal() + ": " + ais.getFluid().getLocalizedName(ais.getFluidStack()));
|
||||
}
|
||||
|
||||
probeInfo.text( isLocked ? TheOneProbeText.LOCKED.getLocal() : TheOneProbeText.UNLOCKED.getLocal() );
|
||||
}
|
||||
}
|
||||
probeInfo.text(isLocked ? TheOneProbeText.LOCKED.getLocal() : TheOneProbeText.UNLOCKED.getLocal());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user