/* * This file ("TileEntityMiner.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 * http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md * View the source code at https://github.com/Ellpeck/ActuallyAdditions * * © 2015 Ellpeck */ package ellpeck.actuallyadditions.tile; import cofh.api.energy.EnergyStorage; import cofh.api.energy.IEnergyReceiver; import net.minecraft.block.Block; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; public class TileEntityMiner extends TileEntityBase implements IEnergyReceiver{ public EnergyStorage storage = new EnergyStorage(800000); @Override public void updateEntity(){ super.updateEntity(); if(!this.worldObj.isRemote){ this.mine(2); } } private void mine(int range){ for(int anX = -range; anX <= range; anX++){ for(int aZ = -range; aZ <= range; aZ++){ for(int y = this.yCoord-1; y > 0; y--){ int x = this.xCoord+anX; int z = this.zCoord+aZ; Block block = this.worldObj.getBlock(x, y, z); int meta = this.worldObj.getBlockMetadata(x, y, z); if(block != null && !block.isAir(this.worldObj, x, y, z)){ if(block.getHarvestLevel(meta) <= 3){ return; } } } } } } @Override public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ super.writeSyncableNBT(compound, sync); this.storage.writeToNBT(compound); } @Override public void readSyncableNBT(NBTTagCompound compound, boolean sync){ super.readSyncableNBT(compound, sync); this.storage.readFromNBT(compound); } @Override public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate){ return this.storage.receiveEnergy(maxReceive, simulate); } @Override public int getEnergyStored(ForgeDirection from){ return this.storage.getEnergyStored(); } @Override public int getMaxEnergyStored(ForgeDirection from){ return this.storage.getMaxEnergyStored(); } @Override public boolean canConnectEnergy(ForgeDirection from){ return true; } }