コード例 #1
0
ファイル: Protection.java プロジェクト: Nerzhei/MyTown2
 private void disableSegment(Iterator<? extends Segment> it, Segment segment, String message) {
   it.remove();
   MyTown.instance.LOG.error(message);
   MyTown.instance.LOG.error(
       "Disabling segment for {} in protection {}.",
       segment.getCheckClass().getName(),
       this.modid);
   MyTown.instance.LOG.info("Reload protections to enable it again.");
 }
コード例 #2
0
 public static void check(TileEntity te) {
   for (SegmentTileEntity segment : segmentsTile.get(te.getClass())) {
     if (!segment.shouldExist(te)) {
       ItemStack itemStack = new ItemStack(te.getBlockType(), 1, te.getBlockMetadata());
       NBTTagCompound nbt = new NBTTagCompound();
       te.writeToNBT(nbt);
       itemStack.setTagCompound(nbt);
       WorldUtils.dropAsEntity(te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord, itemStack);
       te.getWorldObj().setBlock(te.xCoord, te.yCoord, te.zCoord, Blocks.air);
       te.invalidate();
       MyTown.instance.LOG.info("TileEntity {} was ATOMICALLY DISINTEGRATED!", te.toString());
       return;
     }
   }
 }
コード例 #3
0
  /** Gets the nearby tile entities of the specified tile entity and of the specified type */
  public static List<TileEntity> getNearbyTileEntity(
      TileEntity te, Class<? extends TileEntity> type) {
    List<TileEntity> result = new ArrayList<TileEntity>();
    int[] dx = {0, 1, 0, -1, 0, 0};
    int[] dy = {1, 0, -1, 0, 0, 0};
    int[] dz = {0, 0, 0, 0, 1, -1};

    for (int i = 0; i < 6; i++) {
      TileEntity found =
          te.getWorldObj().getTileEntity(te.xCoord + dx[i], te.yCoord + dy[i], te.zCoord + dz[i]);
      if (found != null && type.isAssignableFrom(found.getClass())) {
        MyTown.instance.LOG.info("Found tile entity {} for class {}", found, type.getName());
        result.add(found);
      }
    }
    return result;
  }
コード例 #4
0
ファイル: Segment.java プロジェクト: GameModsBR/MyTown2
 protected void disable() {
   MyTown.instance.LOG.error("Disabling segment for {}", checkClass.getName());
   MyTown.instance.LOG.info("Reload protections to enable it again.");
   this.isDisabled = true;
 }