mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-26 00:38:35 +01:00
Made directional breaker need energy in pulse mode.
Duh.
This commit is contained in:
parent
5f3e8fc748
commit
b3729703b7
1 changed files with 25 additions and 26 deletions
|
@ -26,7 +26,6 @@ import net.minecraftforge.event.ForgeEventFactory;
|
|||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TileEntityDirectionalBreaker extends TileEntityInventoryBase implements IEnergyReceiver, IEnergySaver, IRedstoneToggle{
|
||||
|
@ -62,17 +61,15 @@ public class TileEntityDirectionalBreaker extends TileEntityInventoryBase implem
|
|||
super.updateEntity();
|
||||
if(!this.worldObj.isRemote){
|
||||
if(!this.isRedstonePowered && !this.activateOnceWithSignal){
|
||||
if(this.storage.getEnergyStored() >= ENERGY_USE*RANGE){
|
||||
if(this.currentTime > 0){
|
||||
this.currentTime--;
|
||||
if(this.currentTime <= 0){
|
||||
this.doWork();
|
||||
}
|
||||
}
|
||||
else{
|
||||
this.currentTime = 15;
|
||||
if(this.currentTime > 0){
|
||||
this.currentTime--;
|
||||
if(this.currentTime <= 0){
|
||||
this.doWork();
|
||||
}
|
||||
}
|
||||
else{
|
||||
this.currentTime = 15;
|
||||
}
|
||||
}
|
||||
|
||||
if(this.storage.getEnergyStored() != this.lastEnergy && this.sendUpdateWithInterval()){
|
||||
|
@ -82,25 +79,27 @@ public class TileEntityDirectionalBreaker extends TileEntityInventoryBase implem
|
|||
}
|
||||
|
||||
private void doWork(){
|
||||
EnumFacing sideToManipulate = WorldUtil.getDirectionByPistonRotation(PosUtil.getMetadata(this.pos, this.worldObj));
|
||||
if(this.storage.getEnergyStored() >= ENERGY_USE*RANGE){
|
||||
EnumFacing sideToManipulate = WorldUtil.getDirectionByPistonRotation(PosUtil.getMetadata(this.pos, this.worldObj));
|
||||
|
||||
for(int i = 0; i < RANGE; i++){
|
||||
BlockPos coordsBlock = WorldUtil.getCoordsFromSide(sideToManipulate, this.pos, i);
|
||||
if(coordsBlock != null){
|
||||
Block blockToBreak = PosUtil.getBlock(coordsBlock, this.worldObj);
|
||||
if(blockToBreak != null && !(blockToBreak instanceof BlockAir) && blockToBreak.getBlockHardness(this.worldObj.getBlockState(coordsBlock), this.worldObj, this.pos) > -1.0F){
|
||||
List<ItemStack> drops = blockToBreak.getDrops(this.worldObj, coordsBlock, this.worldObj.getBlockState(coordsBlock), 0);
|
||||
float chance = ForgeEventFactory.fireBlockHarvesting(drops, this.worldObj, coordsBlock, this.worldObj.getBlockState(coordsBlock), 0, 1, false, null);
|
||||
for(int i = 0; i < RANGE; i++){
|
||||
BlockPos coordsBlock = WorldUtil.getCoordsFromSide(sideToManipulate, this.pos, i);
|
||||
if(coordsBlock != null){
|
||||
Block blockToBreak = PosUtil.getBlock(coordsBlock, this.worldObj);
|
||||
if(blockToBreak != null && !(blockToBreak instanceof BlockAir) && blockToBreak.getBlockHardness(this.worldObj.getBlockState(coordsBlock), this.worldObj, this.pos) > -1.0F){
|
||||
List<ItemStack> drops = blockToBreak.getDrops(this.worldObj, coordsBlock, this.worldObj.getBlockState(coordsBlock), 0);
|
||||
float chance = ForgeEventFactory.fireBlockHarvesting(drops, this.worldObj, coordsBlock, this.worldObj.getBlockState(coordsBlock), 0, 1, false, null);
|
||||
|
||||
if(Util.RANDOM.nextFloat() <= chance){
|
||||
if(WorldUtil.addToInventory(this, drops, false, true)){
|
||||
if(!ConfigValues.lessBlockBreakingEffects){
|
||||
this.worldObj.playAuxSFX(2001, coordsBlock, Block.getStateId(this.worldObj.getBlockState(coordsBlock)));
|
||||
if(Util.RANDOM.nextFloat() <= chance){
|
||||
if(WorldUtil.addToInventory(this, drops, false, true)){
|
||||
if(!ConfigValues.lessBlockBreakingEffects){
|
||||
this.worldObj.playAuxSFX(2001, coordsBlock, Block.getStateId(this.worldObj.getBlockState(coordsBlock)));
|
||||
}
|
||||
WorldUtil.breakBlockAtSide(sideToManipulate, this.worldObj, this.getPos(), i);
|
||||
WorldUtil.addToInventory(this, drops, true, true);
|
||||
this.storage.extractEnergy(ENERGY_USE, false);
|
||||
this.markDirty();
|
||||
}
|
||||
WorldUtil.breakBlockAtSide(sideToManipulate, this.worldObj, this.getPos(), i);
|
||||
WorldUtil.addToInventory(this, drops, true, true);
|
||||
this.storage.extractEnergy(ENERGY_USE, false);
|
||||
this.markDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue