protected int getRedstonePower(World world, BlockPos pos, IBlockState state) {
    int var4 = super.getRedstonePower(world, pos, state);
    EnumDirection var5 = state.getValue(DIRECTION);
    BlockPos var6 = pos.offset(var5);
    IBlock var7 = world.getBlockState(var6).getBlock();

    if (var7.hasComparatorInputOverride()) {
      var4 = var7.getComparatorInputOverride(world, var6);
    } else if (var4 < 15 && var7.isNormalCube()) {
      var6 = var6.offset(var5);
      var7 = world.getBlockState(var6).getBlock();

      if (var7.hasComparatorInputOverride()) {
        var4 = var7.getComparatorInputOverride(world, var6);
      } else if (var7.getMaterial() == Material.air) {
        EntityItemFrame var8 = this.func_176461_a(world, var5, var6);

        if (var8 != null) {
          var4 = var8.func_174866_q();
        }
      }
    }

    return var4;
  }
  protected int calculateInputStrength(World worldIn, BlockPos pos, IBlockState state) {
    int i = super.calculateInputStrength(worldIn, pos, state);
    EnumFacing enumfacing = (EnumFacing) state.getValue(FACING);
    BlockPos blockpos = pos.offset(enumfacing);
    IBlockState iblockstate = worldIn.getBlockState(blockpos);

    if (iblockstate.hasComparatorInputOverride()) {
      i = iblockstate.getComparatorInputOverride(worldIn, blockpos);
    } else if (i < 15 && iblockstate.isNormalCube()) {
      blockpos = blockpos.offset(enumfacing);
      iblockstate = worldIn.getBlockState(blockpos);

      if (iblockstate.hasComparatorInputOverride()) {
        i = iblockstate.getComparatorInputOverride(worldIn, blockpos);
      } else if (iblockstate.getMaterial() == Material.AIR) {
        EntityItemFrame entityitemframe = this.findItemFrame(worldIn, enumfacing, blockpos);

        if (entityitemframe != null) {
          i = entityitemframe.getAnalogOutput();
        }
      }
    }

    return i;
  }
Пример #3
0
 @Override
 public boolean equals(Object obj) {
   if (frame == null) return false;
   if (obj instanceof EntityItemFrame) {
     return ((EntityItemFrame) obj).getEntityId() == frame.getEntityId()
         && ((EntityItemFrame) obj).worldObj.isRemote == frame.worldObj.isRemote;
   }
   if (obj instanceof EntityItemFrameComparator) {
     return ((EntityItemFrameComparator) obj).frame.getEntityId() == frame.getEntityId()
         && ((EntityItemFrameComparator) obj).frame.worldObj.isRemote == frame.worldObj.isRemote;
   }
   return false;
 }
Пример #4
0
  private boolean checkFrameRadius(EntityItemFrameComparator frameComp) {

    int radius = 2;

    boolean shouldRemove = true;

    EntityItemFrame frame = frameComp.frame;

    for (int i = -radius; i <= radius; ++i) {
      for (int j = -radius; j <= radius; ++j) {
        for (int k = -radius; k <= radius; ++k) {

          if (frame.worldObj.getBlock(
                  (int) frame.posX + i, (int) frame.posY + j, (int) frame.posZ + k)
              == BlocksCommonProxy.liquidEssence) {

            Integer time = watchedFrames.get(frameComp);
            if (time == null) {
              time = 0;
            }
            time++;

            watchedFrames.put(frameComp, time);

            if (time >= processTime) {
              if (!frame.worldObj.isRemote) {
                frame.setDisplayedItem(new ItemStack(ItemsCommonProxy.arcaneCompendium));
                return true;
              }
            } else {
              shouldRemove = false;
              if (frame.worldObj.isRemote) {
                spawnCompendiumProgressParticles(
                    frame, (int) frame.posX + i, (int) frame.posY + j, (int) frame.posZ + k);
              }
            }
          }
        }
      }
    }

    return shouldRemove;
  }
  protected void hangItemFrame(
      World par1World,
      StructureBoundingBox par2StructureBoundingBox,
      int par3,
      int par4,
      int par5,
      ItemStack item) {
    int j1 = this.getXWithOffset(par3, par5);
    int k1 = this.getYWithOffset(par4);
    int l1 = this.getZWithOffset(par3, par5);

    if (!par2StructureBoundingBox.isVecInside(j1, k1, l1)) {
      return;
    }

    int i1 = this.coordBaseMode;
    EntityItemFrame itemFrame = new EntityItemFrame(par1World, j1, k1, l1, i1);
    itemFrame.setDisplayedItem(item);

    if (itemFrame.onValidSurface()) {
      par1World.spawnEntityInWorld(itemFrame);
    }
  }
Пример #6
0
  /** also sends velocity, rotation, and riding info. */
  public void sendLocationToAllClients(List par1List) {
    this.playerEntitiesUpdated = false;

    if (!this.isDataInitialized
        || this.myEntity.getDistanceSq(this.posX, this.posY, this.posZ) > 16.0D) {
      this.posX = this.myEntity.posX;
      this.posY = this.myEntity.posY;
      this.posZ = this.myEntity.posZ;
      this.isDataInitialized = true;
      this.playerEntitiesUpdated = true;
      this.sendEventsToPlayers(par1List);
    }

    if (this.field_85178_v != this.myEntity.ridingEntity) {
      this.field_85178_v = this.myEntity.ridingEntity;
      this.sendPacketToAllTrackingPlayers(
          new Packet39AttachEntity(this.myEntity, this.myEntity.ridingEntity));
    }

    if (this.myEntity instanceof EntityItemFrame && this.ticks % 10 == 0) {
      EntityItemFrame var23 = (EntityItemFrame) this.myEntity;
      ItemStack var24 = var23.getDisplayedItem();

      if (var24 != null && var24.getItem() instanceof ItemMap) {
        MapData var26 = Item.map.getMapData(var24, this.myEntity.worldObj);
        Iterator var29 = par1List.iterator();

        while (var29.hasNext()) {
          EntityPlayer var30 = (EntityPlayer) var29.next();
          EntityPlayerMP var31 = (EntityPlayerMP) var30;
          var26.updateVisiblePlayers(var31, var24);

          if (var31.playerNetServerHandler.packetSize() <= 5) {
            Packet var32 = Item.map.createMapDataPacket(var24, this.myEntity.worldObj, var31);

            if (var32 != null) {
              var31.playerNetServerHandler.sendPacketToPlayer(var32);
            }
          }
        }
      }

      DataWatcher var28 = this.myEntity.getDataWatcher();

      if (var28.hasChanges()) {
        this.sendPacketToAllAssociatedPlayers(
            new Packet40EntityMetadata(this.myEntity.entityId, var28, false));
      }
    } else if (this.ticks++ % this.updateFrequency == 0 || this.myEntity.isAirBorne) {
      int var2;
      int var3;

      if (this.myEntity.ridingEntity == null) {
        ++this.ticksSinceLastForcedTeleport;
        var2 = this.myEntity.myEntitySize.multiplyBy32AndRound(this.myEntity.posX);
        var3 = MathHelper.floor_double(this.myEntity.posY * 32.0D);
        int var4 = this.myEntity.myEntitySize.multiplyBy32AndRound(this.myEntity.posZ);
        int var5 = MathHelper.floor_float(this.myEntity.rotationYaw * 256.0F / 360.0F);
        int var6 = MathHelper.floor_float(this.myEntity.rotationPitch * 256.0F / 360.0F);
        int var7 = var2 - this.lastScaledXPosition;
        int var8 = var3 - this.lastScaledYPosition;
        int var9 = var4 - this.lastScaledZPosition;
        Object var10 = null;
        boolean var11 =
            Math.abs(var7) >= 4
                || Math.abs(var8) >= 4
                || Math.abs(var9) >= 4
                || this.ticks % 60 == 0;
        boolean var12 = Math.abs(var5 - this.lastYaw) >= 4 || Math.abs(var6 - this.lastPitch) >= 4;

        if (var7 >= -128
            && var7 < 128
            && var8 >= -128
            && var8 < 128
            && var9 >= -128
            && var9 < 128
            && this.ticksSinceLastForcedTeleport <= 400
            && !this.ridingEntity) {
          if (var11 && var12) {
            var10 =
                new Packet33RelEntityMoveLook(
                    this.myEntity.entityId,
                    (byte) var7,
                    (byte) var8,
                    (byte) var9,
                    (byte) var5,
                    (byte) var6);
          } else if (var11) {
            var10 =
                new Packet31RelEntityMove(
                    this.myEntity.entityId, (byte) var7, (byte) var8, (byte) var9);
          } else if (var12) {
            var10 = new Packet32EntityLook(this.myEntity.entityId, (byte) var5, (byte) var6);
          }
        } else {
          this.ticksSinceLastForcedTeleport = 0;
          var10 =
              new Packet34EntityTeleport(
                  this.myEntity.entityId, var2, var3, var4, (byte) var5, (byte) var6);
        }

        if (this.sendVelocityUpdates) {
          double var13 = this.myEntity.motionX - this.motionX;
          double var15 = this.myEntity.motionY - this.motionY;
          double var17 = this.myEntity.motionZ - this.motionZ;
          double var19 = 0.02D;
          double var21 = var13 * var13 + var15 * var15 + var17 * var17;

          if (var21 > var19 * var19
              || var21 > 0.0D
                  && this.myEntity.motionX == 0.0D
                  && this.myEntity.motionY == 0.0D
                  && this.myEntity.motionZ == 0.0D) {
            this.motionX = this.myEntity.motionX;
            this.motionY = this.myEntity.motionY;
            this.motionZ = this.myEntity.motionZ;
            this.sendPacketToAllTrackingPlayers(
                new Packet28EntityVelocity(
                    this.myEntity.entityId, this.motionX, this.motionY, this.motionZ));
          }
        }

        if (var10 != null) {
          this.sendPacketToAllTrackingPlayers((Packet) var10);
        }

        DataWatcher var33 = this.myEntity.getDataWatcher();

        if (var33.hasChanges()) {
          this.sendPacketToAllAssociatedPlayers(
              new Packet40EntityMetadata(this.myEntity.entityId, var33, false));
        }

        if (var11) {
          this.lastScaledXPosition = var2;
          this.lastScaledYPosition = var3;
          this.lastScaledZPosition = var4;
        }

        if (var12) {
          this.lastYaw = var5;
          this.lastPitch = var6;
        }

        this.ridingEntity = false;
      } else {
        var2 = MathHelper.floor_float(this.myEntity.rotationYaw * 256.0F / 360.0F);
        var3 = MathHelper.floor_float(this.myEntity.rotationPitch * 256.0F / 360.0F);
        boolean var25 = Math.abs(var2 - this.lastYaw) >= 4 || Math.abs(var3 - this.lastPitch) >= 4;

        if (var25) {
          this.sendPacketToAllTrackingPlayers(
              new Packet32EntityLook(this.myEntity.entityId, (byte) var2, (byte) var3));
          this.lastYaw = var2;
          this.lastPitch = var3;
        }

        this.lastScaledXPosition =
            this.myEntity.myEntitySize.multiplyBy32AndRound(this.myEntity.posX);
        this.lastScaledYPosition = MathHelper.floor_double(this.myEntity.posY * 32.0D);
        this.lastScaledZPosition =
            this.myEntity.myEntitySize.multiplyBy32AndRound(this.myEntity.posZ);
        DataWatcher var27 = this.myEntity.getDataWatcher();

        if (var27.hasChanges()) {
          this.sendPacketToAllAssociatedPlayers(
              new Packet40EntityMetadata(this.myEntity.entityId, var27, false));
        }

        this.ridingEntity = true;
      }

      var2 = MathHelper.floor_float(this.myEntity.setRotationYawHead() * 256.0F / 360.0F);

      if (Math.abs(var2 - this.lastHeadMotion) >= 4) {
        this.sendPacketToAllTrackingPlayers(
            new Packet35EntityHeadRotation(this.myEntity.entityId, (byte) var2));
        this.lastHeadMotion = var2;
      }

      this.myEntity.isAirBorne = false;
    }

    if (this.myEntity.velocityChanged) {
      this.sendPacketToAllAssociatedPlayers(new Packet28EntityVelocity(this.myEntity));
      this.myEntity.velocityChanged = false;
    }
  }
Пример #7
0
 @Override
 public int hashCode() {
   if (frame == null || frame.worldObj == null) return 0;
   return frame.getEntityId() + (frame.worldObj.isRemote ? 1 : 2);
 }
Пример #8
0
 private boolean frameIsValid(EntityItemFrame frame) {
   return frame != null
       && !frame.isDead
       && frame.getDisplayedItem() != null
       && frame.getDisplayedItem().getItem() instanceof ItemBook;
 }