Esempio n. 1
0
 /**
  * Returns one of DiamondLeggings sub-type based on sub-id.
  *
  * @param id sub-type id
  * @return sub-type of DiamondLeggings.
  */
 public static DiamondLeggingsMat getByID(final int id) {
   DiamondLeggingsMat mat = byID.get((short) id);
   if (mat == null) {
     mat = new DiamondLeggingsMat(id);
     if ((id > 0) && (id < DIAMOND_LEGGINGS.getBaseDurability())) {
       DiamondLeggingsMat.register(mat);
     }
   }
   return mat;
 }
Esempio n. 2
0
 /**
  * Returns one of IronChestplate sub-type based on sub-id.
  *
  * @param id sub-type id
  * @return sub-type of IronChestplate.
  */
 public static IronChestplateMat getByID(final int id) {
   IronChestplateMat mat = byID.get((short) id);
   if (mat == null) {
     mat = new IronChestplateMat(id);
     if ((id > 0) && (id < IRON_CHESTPLATE.getBaseDurability())) {
       IronChestplateMat.register(mat);
     }
   }
   return mat;
 }
Esempio n. 3
0
 /**
  * Returns one of StoneAxe sub-type based on sub-id.
  *
  * @param id sub-type id
  * @return sub-type of StoneAxe.
  */
 public static StoneAxeMat getByID(final int id) {
   StoneAxeMat mat = byID.get((short) id);
   if (mat == null) {
     mat = new StoneAxeMat(id);
     if ((id > 0) && (id < STONE_AXE.getBaseDurability())) {
       StoneAxeMat.register(mat);
     }
   }
   return mat;
 }
  private TShortObjectMap<TIntList> createBatchBlockEventMappings(Chunk chunk) {
    TShortObjectMap<TIntList> batchBlockMap = new TShortObjectHashMap<>();
    for (Block block : blockManager.listRegisteredBlocks()) {
      if (block.isLifecycleEventsRequired()) {
        batchBlockMap.put(block.getId(), new TIntArrayList());
      }
    }

    ChunkBlockIterator i = chunk.getBlockIterator();
    while (i.next()) {
      if (i.getBlock().isLifecycleEventsRequired()) {
        TIntList positionList = batchBlockMap.get(i.getBlock().getId());
        positionList.add(i.getBlockPos().x);
        positionList.add(i.getBlockPos().y);
        positionList.add(i.getBlockPos().z);
      }
    }
    return batchBlockMap;
  }
 private void deactivateBlocks() {
   List<TShortObjectMap<TIntList>> deactivatedBlockSets =
       Lists.newArrayListWithExpectedSize(deactivateBlocksQueue.size());
   deactivateBlocksQueue.drainTo(deactivatedBlockSets);
   for (TShortObjectMap<TIntList> deactivatedBlockSet : deactivatedBlockSets) {
     deactivatedBlockSet.forEachEntry(
         new TShortObjectProcedure<TIntList>() {
           @Override
           public boolean execute(short id, TIntList positions) {
             if (positions.size() > 0) {
               blockManager
                   .getBlock(id)
                   .getEntity()
                   .send(new BeforeDeactivateBlocks(positions, registry));
             }
             return true;
           }
         });
   }
 }
Esempio n. 6
0
 /** @return array that contains all sub-types of this block. */
 public static BowlMat[] bowlTypes() {
   return byID.values(new BowlMat[byID.size()]);
 }
Esempio n. 7
0
 /**
  * Register new sub-type, may replace existing sub-types. Should be used only if you know what are
  * you doing, it will not create fully usable material.
  *
  * @param element sub-type to register
  */
 public static void register(final BowlMat element) {
   byID.put(element.getType(), element);
   byName.put(element.getTypeName(), element);
 }
Esempio n. 8
0
 /**
  * Returns one of Bowl sub-type based on sub-id, may return null
  *
  * @param id sub-type id
  * @return sub-type of Bowl or null
  */
 public static BowlMat getByID(final int id) {
   return byID.get((short) id);
 }
Esempio n. 9
0
 /**
  * Register new sub-type, may replace existing sub-types. Should be used only if you know what are
  * you doing, it will not create fully usable material.
  *
  * @param element sub-type to register
  */
 public static void register(final DiamondLeggingsMat element) {
   byID.put(element.getType(), element);
   byName.put(element.getTypeName(), element);
 }
Esempio n. 10
0
 /**
  * Register new sub-type, may replace existing sub-types. Should be used only if you know what are
  * you doing, it will not create fully usable material.
  *
  * @param element sub-type to register
  */
 public static void register(final IronChestplateMat element) {
   byID.put(element.getType(), element);
   byName.put(element.getTypeName(), element);
 }
Esempio n. 11
0
 /** @return array that contains all sub-types of this block. */
 public static BakedPotatoMat[] bakedPotatoTypes() {
   return byID.values(new BakedPotatoMat[byID.size()]);
 }
Esempio n. 12
0
 /**
  * Returns one of BakedPotato sub-type based on sub-id, may return null
  *
  * @param id sub-type id
  * @return sub-type of BakedPotato or null
  */
 public static BakedPotatoMat getByID(final int id) {
   return byID.get((short) id);
 }