All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.minecraft.server.BlockStatePredicate Maven / Gradle / Ivy

There is a newer version: 2.4.0
Show newest version
package net.minecraft.server;

import com.google.common.base.Predicate;
import com.google.common.collect.Maps;

import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;

public class BlockStatePredicate implements Predicate {

  private final BlockStateList a;
  private final Map b = Maps.newHashMap();

  private BlockStatePredicate(BlockStateList blockstatelist) {
    this.a = blockstatelist;
  }

  public static BlockStatePredicate a(Block block) {
    return new BlockStatePredicate(block.P());
  }

  public boolean a(IBlockData iblockdata) {
    if (iblockdata != null && iblockdata.getBlock().equals(this.a.getBlock())) {
      Iterator> iterator = this.b.entrySet().iterator();

      Entry entry;
      Comparable comparable;

      do {
        if (!iterator.hasNext()) {
          return true;
        }

        entry = iterator.next();
        comparable = iblockdata.get((IBlockState) entry.getKey());
      } while (((Predicate) entry.getValue()).apply(comparable));
  
    }
    return false;
  }

  public > BlockStatePredicate a(IBlockState iblockstate, Predicate predicate) {
    if (!this.a.d().contains(iblockstate)) {
      throw new IllegalArgumentException(this.a + " cannot support property " + iblockstate);
    } else {
      this.b.put(iblockstate, predicate);
      return this;
    }
  }

  public boolean apply(IBlockData object) {
    return this.a(object);
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy