ActuallyAdditions/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomEnergyface.java

66 lines
1.9 KiB
Java
Raw Normal View History

/*
2016-05-16 22:52:27 +02:00
* This file ("TileEntityPhantomEnergyface.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
2016-05-16 22:52:27 +02:00
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
2017-01-01 16:23:26 +01:00
* © 2015-2017 Ellpeck
*/
2016-01-05 04:47:35 +01:00
package de.ellpeck.actuallyadditions.mod.tile;
2016-01-05 04:47:35 +01:00
import de.ellpeck.actuallyadditions.mod.blocks.BlockPhantom;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.energy.CapabilityEnergy;
2019-05-02 09:10:29 +02:00
public class TileEntityPhantomEnergyface extends TileEntityPhantomface implements ISharingEnergyProvider {
2019-05-02 09:10:29 +02:00
public TileEntityPhantomEnergyface() {
2021-02-27 16:33:00 +01:00
super(ActuallyTiles.PHANTOMENERGYFACE_TILE.get());
this.type = BlockPhantom.Type.ENERGYFACE;
}
@Override
2019-05-02 09:10:29 +02:00
public boolean isBoundThingInRange() {
if (super.isBoundThingInRange()) {
2016-11-26 21:32:27 +01:00
TileEntity tile = this.world.getTileEntity(this.boundPosition);
2019-05-02 09:10:29 +02:00
if (tile != null && !(tile instanceof TileEntityLaserRelayEnergy)) {
for (Direction facing : Direction.values()) {
2021-02-27 16:33:00 +01:00
if (tile.getCapability(CapabilityEnergy.ENERGY, facing).isPresent()) {
return true;
}
}
}
}
return false;
}
@Override
2019-05-02 09:10:29 +02:00
protected boolean isCapabilitySupported(Capability<?> capability) {
return capability == CapabilityEnergy.ENERGY;
}
@Override
2019-05-02 09:10:29 +02:00
public int getEnergyToSplitShare() {
return Integer.MAX_VALUE;
}
@Override
2019-05-02 09:10:29 +02:00
public boolean doesShareEnergy() {
return true;
}
@Override
public Direction[] getEnergyShareSides() {
return Direction.values();
}
@Override
2019-05-02 09:10:29 +02:00
public boolean canShareTo(TileEntity tile) {
return true;
}
}