示例#1
0
 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
 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;
 }