mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-21 20:52:42 +00:00
#1456 Allow wireless charger to be disabled with redstone
This commit is contained in:
1 parent
5dd479f5e6
commit
96beafa468
7 files changed
+30
-8
No files matched your search
@@ -40,8 +40,12 @@ public abstract class TileEntityEio extends TileEntity {
|
||||
protected abstract void readCustomNBT(NBTTagCompound root);
|
||||
|
||||
protected void updateBlock() {
|
||||
if (worldObj != null) {
|
||||
if(worldObj != null) {
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean isPoweredRedstone() {
|
||||
return worldObj.getStrongestIndirectPower(xCoord, yCoord, zCoord) > 0;
|
||||
}
|
||||
}
|
||||
@@ -231,7 +231,7 @@ public abstract class AbstractMachineBlock<T extends AbstractMachineEntity> exte
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z) {
|
||||
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean doHarvest) {
|
||||
if(!world.isRemote && (!player.capabilities.isCreativeMode)) {
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if(te instanceof AbstractMachineEntity) {
|
||||
@@ -250,7 +250,7 @@ public abstract class AbstractMachineBlock<T extends AbstractMachineEntity> exte
|
||||
world.spawnEntityInWorld(entityitem);
|
||||
}
|
||||
}
|
||||
return super.removedByPlayer(world, player, x, y, z);
|
||||
return super.removedByPlayer(world, player, x, y, z, doHarvest);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -65,7 +65,7 @@ public class BlockWirelessCharger extends BlockEio implements IResourceTooltipPr
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if(te instanceof TileWirelessCharger) {
|
||||
TileWirelessCharger twc = (TileWirelessCharger) te;
|
||||
if(twc.getEnergyStored() > 0) {
|
||||
if(twc.isActive()) {
|
||||
return centerOn;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,14 @@ public interface IWirelessCharger {
|
||||
BlockCoord getLocation();
|
||||
|
||||
boolean chargeItems(ItemStack[] armorInventory);
|
||||
|
||||
|
||||
int takeEnergy(int max);
|
||||
|
||||
/**
|
||||
* Can prevent {@link #chargeItems(ItemStack[])} from being called.
|
||||
*
|
||||
* @return If this charger is "active". If the charger is not active it will
|
||||
* not be attempted to be used.
|
||||
*/
|
||||
boolean isActive();
|
||||
}
|
||||
@@ -159,4 +159,8 @@ public class TileWirelessCharger extends TileEntityEio implements IInternalPower
|
||||
public boolean displayPower() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isActive() {
|
||||
return getEnergyStored() > 0 && !isPoweredRedstone();
|
||||
}
|
||||
}
|
||||
@@ -60,9 +60,9 @@ public class WirelessChargerController {
|
||||
if(chargers.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
BlockCoord bc = new BlockCoord((int) player.posX, (int) player.posY, (int) player.posZ);
|
||||
BlockCoord bc = new BlockCoord(player);
|
||||
for (IWirelessCharger capBank : chargers.values()) {
|
||||
if(capBank.getLocation().distanceSquared(bc) <= RANGE_SQ) {
|
||||
if(capBank.isActive() && capBank.getLocation().distanceSquared(bc) <= RANGE_SQ) {
|
||||
boolean done = chargeFromCapBank(player, capBank);
|
||||
if(done) {
|
||||
return;
|
||||
|
||||
@@ -2,7 +2,9 @@ package crazypants.util;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
@@ -21,6 +23,10 @@ public final class BlockCoord {
|
||||
public BlockCoord(TileEntity tile) {
|
||||
this(tile.xCoord, tile.yCoord, tile.zCoord);
|
||||
}
|
||||
|
||||
public BlockCoord(Entity e) {
|
||||
this(MathHelper.floor_double(e.posX), MathHelper.floor_double(e.posY), MathHelper.floor_double(e.posZ));
|
||||
}
|
||||
|
||||
public BlockCoord(BlockCoord bc) {
|
||||
x = bc.x;
|
||||
|
||||
Reference in new issue
Block a user