added redstone mode to the ranged collector because jose is a whiny bitch

This commit is contained in:
Ellpeck 2017-02-06 14:55:54 +01:00
parent 10439db8ca
commit ca169cd089
3 changed files with 33 additions and 23 deletions

View file

@ -44,6 +44,9 @@ public class BlockRangedCollector extends BlockContainerBase{
@Override @Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9){ public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, 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){

View file

@ -121,11 +121,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;
} }

View file

@ -47,30 +47,40 @@ public class TileEntityRangedCollector extends TileEntityInventoryBase implement
} }
@Override @Override
public void updateEntity(){ public boolean isRedstoneToggle(){
super.updateEntity(); return true;
if(!this.world.isRemote){ }
if(!this.isRedstonePowered){
ArrayList<EntityItem> items = (ArrayList<EntityItem>)this.world.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()){
for(EntityItem item : items){
if(!item.isDead && !item.cannotPickup() && StackUtil.isValid(item.getEntityItem())){
ItemStack toAdd = item.getEntityItem().copy();
if(this.filter.check(toAdd)){
ArrayList<ItemStack> checkList = new ArrayList<ItemStack>();
checkList.add(toAdd);
if(WorldUtil.addToInventory(this.slots, checkList, false)){
WorldUtil.addToInventory(this.slots, checkList, true);
((WorldServer)this.world).spawnParticle(EnumParticleTypes.CLOUD, false, item.posX, item.posY+0.45F, item.posZ, 5, 0, 0, 0, 0.03D); @Override
public void activateOnPulse(){
ArrayList<EntityItem> items = (ArrayList<EntityItem>)this.world.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()){
for(EntityItem item : items){
if(!item.isDead && !item.cannotPickup() && StackUtil.isValid(item.getEntityItem())){
ItemStack toAdd = item.getEntityItem().copy();
if(this.filter.check(toAdd)){
ArrayList<ItemStack> checkList = new ArrayList<ItemStack>();
checkList.add(toAdd);
if(WorldUtil.addToInventory(this.slots, checkList, false)){
WorldUtil.addToInventory(this.slots, checkList, true);
item.setDead(); ((WorldServer)this.world).spawnParticle(EnumParticleTypes.CLOUD, false, item.posX, item.posY+0.45F, item.posZ, 5, 0, 0, 0, 0.03D);
}
} item.setDead();
} }
} }
} }
} }
}
}
@Override
public void updateEntity(){
super.updateEntity();
if(!this.world.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();