mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-14 20:29:08 +01:00
added a pulse mode to the ranged collector
This commit is contained in:
parent
df0f0aed58
commit
34bf9e4aa7
3 changed files with 34 additions and 24 deletions
|
@ -44,6 +44,10 @@ public class BlockRangedCollector extends BlockContainerBase{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack stack, EnumFacing par6, float par7, float par8, float par9){
|
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack stack, EnumFacing par6, float par7, float par8, float par9){
|
||||||
|
if(this.tryToggleRedstone(world, pos, player)){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if(!world.isRemote){
|
if(!world.isRemote){
|
||||||
TileEntityRangedCollector breaker = (TileEntityRangedCollector)world.getTileEntity(pos);
|
TileEntityRangedCollector breaker = (TileEntityRangedCollector)world.getTileEntity(pos);
|
||||||
if(breaker != null){
|
if(breaker != null){
|
||||||
|
|
|
@ -18,7 +18,6 @@ import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockContainer;
|
import net.minecraft.block.BlockContainer;
|
||||||
import net.minecraft.block.BlockRedstoneTorch;
|
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.block.properties.PropertyInteger;
|
import net.minecraft.block.properties.PropertyInteger;
|
||||||
import net.minecraft.block.state.BlockStateContainer;
|
import net.minecraft.block.state.BlockStateContainer;
|
||||||
|
@ -118,11 +117,8 @@ public abstract class BlockContainerBase extends BlockContainer implements ItemB
|
||||||
TileEntityBase base = (TileEntityBase)tile;
|
TileEntityBase base = (TileEntityBase)tile;
|
||||||
if(!world.isRemote && base.isRedstoneToggle()){
|
if(!world.isRemote && base.isRedstoneToggle()){
|
||||||
base.isPulseMode = !base.isPulseMode;
|
base.isPulseMode = !base.isPulseMode;
|
||||||
tile.markDirty();
|
base.markDirty();
|
||||||
|
base.sendUpdate();
|
||||||
if(tile instanceof TileEntityBase){
|
|
||||||
((TileEntityBase)tile).sendUpdate();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,10 +51,12 @@ public class TileEntityRangedCollector extends TileEntityInventoryBase implement
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateEntity(){
|
public boolean isRedstoneToggle(){
|
||||||
super.updateEntity();
|
return true;
|
||||||
if(!this.worldObj.isRemote){
|
}
|
||||||
if(!this.isRedstonePowered){
|
|
||||||
|
@Override
|
||||||
|
public void activateOnPulse(){
|
||||||
ArrayList<EntityItem> items = (ArrayList<EntityItem>)this.worldObj.getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(this.pos.getX()-RANGE, this.pos.getY()-RANGE, this.pos.getZ()-RANGE, this.pos.getX()+RANGE, this.pos.getY()+RANGE, this.pos.getZ()+RANGE));
|
ArrayList<EntityItem> items = (ArrayList<EntityItem>)this.worldObj.getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(this.pos.getX()-RANGE, this.pos.getY()-RANGE, this.pos.getZ()-RANGE, this.pos.getX()+RANGE, this.pos.getY()+RANGE, this.pos.getZ()+RANGE));
|
||||||
if(!items.isEmpty()){
|
if(!items.isEmpty()){
|
||||||
for(EntityItem item : items){
|
for(EntityItem item : items){
|
||||||
|
@ -76,6 +78,14 @@ public class TileEntityRangedCollector extends TileEntityInventoryBase implement
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateEntity(){
|
||||||
|
super.updateEntity();
|
||||||
|
if(!this.worldObj.isRemote){
|
||||||
|
if(!this.isRedstonePowered && !this.isPulseMode){
|
||||||
|
this.activateOnPulse();
|
||||||
|
}
|
||||||
|
|
||||||
if(this.filter.needsUpdateSend() && this.sendUpdateWithInterval()){
|
if(this.filter.needsUpdateSend() && this.sendUpdateWithInterval()){
|
||||||
this.filter.updateLasts();
|
this.filter.updateLasts();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue