1.15 port
This commit is contained in:
@@ -23,8 +23,8 @@ import java.util.EnumSet;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
|
||||
@@ -50,7 +50,7 @@ public abstract class AEBasePoweredTile extends AEBaseInvTile implements IAEPowe
|
||||
private AccessRestriction internalPowerFlow = AccessRestriction.READ_WRITE;
|
||||
// the current power buffer.
|
||||
private double internalCurrentPower = 0;
|
||||
private EnumSet<EnumFacing> internalPowerSides = EnumSet.allOf( EnumFacing.class );
|
||||
private EnumSet<Direction> internalPowerSides = EnumSet.allOf( Direction.class );
|
||||
private final IEnergyStorage forgeEnergyAdapter;
|
||||
private Object teslaEnergyAdapter;
|
||||
|
||||
@@ -67,12 +67,12 @@ public abstract class AEBasePoweredTile extends AEBaseInvTile implements IAEPowe
|
||||
this.ic2Sink.setValidFaces( this.internalPowerSides );
|
||||
}
|
||||
|
||||
protected EnumSet<EnumFacing> getPowerSides()
|
||||
protected EnumSet<Direction> getPowerSides()
|
||||
{
|
||||
return this.internalPowerSides.clone();
|
||||
}
|
||||
|
||||
protected void setPowerSides( final EnumSet<EnumFacing> sides )
|
||||
protected void setPowerSides( final EnumSet<Direction> sides )
|
||||
{
|
||||
this.internalPowerSides = sides;
|
||||
this.ic2Sink.setValidFaces( sides );
|
||||
@@ -80,7 +80,7 @@ public abstract class AEBasePoweredTile extends AEBaseInvTile implements IAEPowe
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT( final NBTTagCompound data )
|
||||
public CompoundNBT writeToNBT( final CompoundNBT data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
data.setDouble( "internalCurrentPower", this.getInternalCurrentPower() );
|
||||
@@ -88,7 +88,7 @@ public abstract class AEBasePoweredTile extends AEBaseInvTile implements IAEPowe
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT( final NBTTagCompound data )
|
||||
public void readFromNBT( final CompoundNBT data )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
this.setInternalCurrentPower( data.getDouble( "internalCurrentPower" ) );
|
||||
@@ -268,7 +268,7 @@ public abstract class AEBasePoweredTile extends AEBaseInvTile implements IAEPowe
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability( Capability<?> capability, EnumFacing facing )
|
||||
public boolean hasCapability( Capability<?> capability, Direction facing )
|
||||
{
|
||||
if( capability == Capabilities.FORGE_ENERGY )
|
||||
{
|
||||
@@ -290,7 +290,7 @@ public abstract class AEBasePoweredTile extends AEBaseInvTile implements IAEPowe
|
||||
|
||||
@SuppressWarnings( "unchecked" )
|
||||
@Override
|
||||
public <T> T getCapability( Capability<T> capability, @Nullable EnumFacing facing )
|
||||
public <T> T getCapability( Capability<T> capability, @Nullable Direction facing )
|
||||
{
|
||||
if( capability == Capabilities.FORGE_ENERGY )
|
||||
{
|
||||
|
||||
@@ -1,51 +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.tile.powersink;
|
||||
|
||||
|
||||
import net.darkhax.tesla.api.ITeslaConsumer;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.PowerUnits;
|
||||
|
||||
|
||||
/**
|
||||
* Adapts an {@link IExternalPowerSink} to Forges {@link net.darkhax.tesla.api.ITeslaConsumer}.
|
||||
*/
|
||||
class TeslaEnergyAdapter implements ITeslaConsumer
|
||||
{
|
||||
|
||||
private final IExternalPowerSink sink;
|
||||
|
||||
TeslaEnergyAdapter( IExternalPowerSink sink )
|
||||
{
|
||||
this.sink = sink;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long givePower( long power, boolean simulated )
|
||||
{
|
||||
// Cut it down to what we can represent in a double
|
||||
double offeredPower = power;
|
||||
|
||||
final double overflow = this.sink.injectExternalPower( PowerUnits.RF, offeredPower, simulated ? Actionable.SIMULATE : Actionable.MODULATE );
|
||||
|
||||
return (long) ( power - overflow );
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user