/** Render a skull tile entity. */
 public void renderTileEntitySkullAt(
     TileEntitySkull par1TileEntitySkull, double par2, double par4, double par6, float par8) {
   this.func_82393_a(
       (float) par2,
       (float) par4,
       (float) par6,
       par1TileEntitySkull.getBlockMetadata() & 7,
       (float) (par1TileEntitySkull.func_82119_b() * 360) / 16.0F,
       par1TileEntitySkull.func_82117_a(),
       par1TileEntitySkull.func_82120_c());
 }
 public void renderTileEntityAt(
     TileEntitySkull te, double x, double y, double z, float partialTicks, int destroyStage) {
   EnumFacing enumfacing = EnumFacing.getFront(te.getBlockMetadata() & 7);
   this.renderSkull(
       (float) x,
       (float) y,
       (float) z,
       enumfacing,
       (float) (te.getSkullRotation() * 360) / 16.0F,
       te.getSkullType(),
       te.getPlayerProfile(),
       destroyStage);
 }
Beispiel #3
0
  /** Called when an ItemStack with NBT data is read to potentially that ItemStack's NBT data */
  public boolean updateItemStackNBT(NBTTagCompound nbt) {
    super.updateItemStackNBT(nbt);

    if (nbt.hasKey("SkullOwner", 8) && nbt.getString("SkullOwner").length() > 0) {
      GameProfile gameprofile = new GameProfile((UUID) null, nbt.getString("SkullOwner"));
      gameprofile = TileEntitySkull.updateGameprofile(gameprofile);
      nbt.setTag("SkullOwner", NBTUtil.writeGameProfile(new NBTTagCompound(), gameprofile));
      return true;
    } else {
      return false;
    }
  }
  public void renderByItem(ItemStack p_179022_1_) {
    if (p_179022_1_.getItem() == Items.banner) {
      this.banner.setItemValues(p_179022_1_);
      TileEntityRendererDispatcher.instance.renderTileEntityAt(this.banner, 0.0D, 0.0D, 0.0D, 0.0F);
    } else if (p_179022_1_.getItem() == Items.skull) {
      GameProfile gameprofile = null;

      if (p_179022_1_.hasTagCompound()) {
        NBTTagCompound nbttagcompound = p_179022_1_.getTagCompound();

        if (nbttagcompound.hasKey("SkullOwner", 10)) {
          gameprofile = NBTUtil.readGameProfileFromNBT(nbttagcompound.getCompoundTag("SkullOwner"));
        } else if (nbttagcompound.hasKey("SkullOwner", 8)
            && nbttagcompound.getString("SkullOwner").length() > 0) {
          gameprofile = new GameProfile((UUID) null, nbttagcompound.getString("SkullOwner"));
          gameprofile = TileEntitySkull.updateGameprofile(gameprofile);
          nbttagcompound.removeTag("SkullOwner");
          nbttagcompound.setTag(
              "SkullOwner", NBTUtil.writeGameProfile(new NBTTagCompound(), gameprofile));
        }
      }

      if (TileEntitySkullRenderer.instance != null) {
        GlStateManager.pushMatrix();
        GlStateManager.translate(-0.5F, 0.0F, -0.5F);
        GlStateManager.scale(2.0F, 2.0F, 2.0F);
        GlStateManager.disableCull();
        TileEntitySkullRenderer.instance.renderSkull(
            0.0F, 0.0F, 0.0F, EnumFacing.UP, 0.0F, p_179022_1_.getMetadata(), gameprofile, -1);
        GlStateManager.enableCull();
        GlStateManager.popMatrix();
      }
    } else {
      Block block = Block.getBlockFromItem(p_179022_1_.getItem());

      if (block == Blocks.ender_chest) {
        TileEntityRendererDispatcher.instance.renderTileEntityAt(
            this.field_147716_d, 0.0D, 0.0D, 0.0D, 0.0F);
      } else if (block == Blocks.trapped_chest) {
        TileEntityRendererDispatcher.instance.renderTileEntityAt(
            this.field_147718_c, 0.0D, 0.0D, 0.0D, 0.0F);
      } else {
        TileEntityRendererDispatcher.instance.renderTileEntityAt(
            this.field_147717_b, 0.0D, 0.0D, 0.0D, 0.0F);
      }
    }
  }
Beispiel #5
0
  /** Called when a Block is right-clicked with this Item */
  public boolean onItemUse(
      ItemStack stack,
      EntityPlayer playerIn,
      World worldIn,
      BlockPos pos,
      EnumFacing side,
      float hitX,
      float hitY,
      float hitZ) {
    if (side == EnumFacing.DOWN) {
      return false;
    } else {
      IBlockState iblockstate = worldIn.getBlockState(pos);
      Block block = iblockstate.getBlock();
      boolean flag = block.isReplaceable(worldIn, pos);

      if (!flag) {
        if (!worldIn.getBlockState(pos).getBlock().getMaterial().isSolid()) {
          return false;
        }

        pos = pos.offset(side);
      }

      if (!playerIn.canPlayerEdit(pos, side, stack)) {
        return false;
      } else if (!Blocks.skull.canPlaceBlockAt(worldIn, pos)) {
        return false;
      } else {
        if (!worldIn.isRemote) {
          worldIn.setBlockState(
              pos, Blocks.skull.getDefaultState().withProperty(BlockSkull.FACING, side), 3);
          int i = 0;

          if (side == EnumFacing.UP) {
            i =
                MathHelper.floor_double((double) (playerIn.rotationYaw * 16.0F / 360.0F) + 0.5D)
                    & 15;
          }

          TileEntity tileentity = worldIn.getTileEntity(pos);

          if (tileentity instanceof TileEntitySkull) {
            TileEntitySkull tileentityskull = (TileEntitySkull) tileentity;

            if (stack.getMetadata() == 3) {
              GameProfile gameprofile = null;

              if (stack.hasTagCompound()) {
                NBTTagCompound nbttagcompound = stack.getTagCompound();

                if (nbttagcompound.hasKey("SkullOwner", 10)) {
                  gameprofile =
                      NBTUtil.readGameProfileFromNBT(nbttagcompound.getCompoundTag("SkullOwner"));
                } else if (nbttagcompound.hasKey("SkullOwner", 8)
                    && nbttagcompound.getString("SkullOwner").length() > 0) {
                  gameprofile =
                      new GameProfile((UUID) null, nbttagcompound.getString("SkullOwner"));
                }
              }

              tileentityskull.setPlayerProfile(gameprofile);
            } else {
              tileentityskull.setType(stack.getMetadata());
            }

            tileentityskull.setSkullRotation(i);
            Blocks.skull.checkWitherSpawn(worldIn, pos, tileentityskull);
          }

          --stack.stackSize;
        }

        return true;
      }
    }
  }
Beispiel #6
0
  // Copied from vanila skull itemBlock. Relevant edits are indicated.
  @Nonnull
  @Override
  public EnumActionResult onItemUse(
      ItemStack stack,
      EntityPlayer playerIn,
      World worldIn,
      BlockPos pos,
      EnumHand hand,
      EnumFacing facing,
      float hitX,
      float hitY,
      float hitZ) {
    if (facing == EnumFacing.DOWN) {
      return EnumActionResult.FAIL;
    } else {
      if (worldIn.getBlockState(pos).getBlock().isReplaceable(worldIn, pos)) {
        facing = EnumFacing.UP;
        pos = pos.down();
      }
      IBlockState iblockstate = worldIn.getBlockState(pos);
      Block block = iblockstate.getBlock();
      boolean flag = block.isReplaceable(worldIn, pos);

      if (!flag) {
        if (!worldIn.getBlockState(pos).getMaterial().isSolid()
            && !worldIn.isSideSolid(pos, facing, true)) {
          return EnumActionResult.FAIL;
        }

        pos = pos.offset(facing);
      }

      if (playerIn.canPlayerEdit(pos, facing, stack)
          && Blocks.SKULL.canPlaceBlockAt(worldIn, pos)) {
        if (worldIn.isRemote) {
          return EnumActionResult.SUCCESS;
        } else {
          worldIn.setBlockState(
              pos,
              ModBlocks.gaiaHead.getDefaultState().withProperty(BlockSkull.FACING, facing),
              11); // Botania - skull -> gaia head
          int i = 0;

          if (facing == EnumFacing.UP) {
            i = MathHelper.floor_double(playerIn.rotationYaw * 16.0F / 360.0F + 0.5D) & 15;
          }

          TileEntity tileentity = worldIn.getTileEntity(pos);

          if (tileentity instanceof TileEntitySkull) {
            TileEntitySkull tileentityskull = (TileEntitySkull) tileentity;

            if (stack.getMetadata() == 3) // Botania - do not retrieve skins
            {
              /*GameProfile gameprofile = null;

              if (stack.hasTagCompound())
              {
              	NBTTagCompound nbttagcompound = stack.getTagCompound();

              	if (nbttagcompound.hasKey("SkullOwner", 10))
              	{
              		gameprofile = NBTUtil.readGameProfileFromNBT(nbttagcompound.getCompoundTag("SkullOwner"));
              	}
              	else if (nbttagcompound.hasKey("SkullOwner", 8) && !nbttagcompound.getString("SkullOwner").isEmpty())
              	{
              		gameprofile = new GameProfile((UUID)null, nbttagcompound.getString("SkullOwner"));
              	}
              }

              tileentityskull.setPlayerProfile(gameprofile);*/
            } else {
              tileentityskull.setType(3); // Botania - Force type to 3 (humanoid)
            }

            tileentityskull.setSkullRotation(i);
            Blocks.SKULL.checkWitherSpawn(worldIn, pos, tileentityskull);
          }

          --stack.stackSize;
          return EnumActionResult.SUCCESS;
        }
      } else {
        return EnumActionResult.FAIL;
      }
    }
  }
  public boolean func_77648_a(
      ItemStack p_77648_1_,
      EntityPlayer p_77648_2_,
      World p_77648_3_,
      int p_77648_4_,
      int p_77648_5_,
      int p_77648_6_,
      int p_77648_7_,
      float p_77648_8_,
      float p_77648_9_,
      float p_77648_10_) {
    if (p_77648_7_ == 0) {
      return false;
    } else if (!p_77648_3_.func_72803_f(p_77648_4_, p_77648_5_, p_77648_6_).func_76220_a()) {
      return false;
    } else {
      if (p_77648_7_ == 1) {
        ++p_77648_5_;
      }

      if (p_77648_7_ == 2) {
        --p_77648_6_;
      }

      if (p_77648_7_ == 3) {
        ++p_77648_6_;
      }

      if (p_77648_7_ == 4) {
        --p_77648_4_;
      }

      if (p_77648_7_ == 5) {
        ++p_77648_4_;
      }

      if (!p_77648_2_.func_82247_a(p_77648_4_, p_77648_5_, p_77648_6_, p_77648_7_, p_77648_1_)) {
        return false;
      } else if (!Block.field_82512_cj.func_71930_b(
          p_77648_3_, p_77648_4_, p_77648_5_, p_77648_6_)) {
        return false;
      } else {
        p_77648_3_.func_72832_d(
            p_77648_4_, p_77648_5_, p_77648_6_, Block.field_82512_cj.field_71990_ca, p_77648_7_, 2);
        int var11 = 0;
        if (p_77648_7_ == 1) {
          var11 =
              MathHelper.func_76128_c((double) (p_77648_2_.field_70177_z * 16.0F / 360.0F) + 0.5D)
                  & 15;
        }

        TileEntity var12 = p_77648_3_.func_72796_p(p_77648_4_, p_77648_5_, p_77648_6_);
        if (var12 != null && var12 instanceof TileEntitySkull) {
          String var13 = "";
          if (p_77648_1_.func_77942_o() && p_77648_1_.func_77978_p().func_74764_b("SkullOwner")) {
            var13 = p_77648_1_.func_77978_p().func_74779_i("SkullOwner");
          }

          ((TileEntitySkull) var12).func_82118_a(p_77648_1_.func_77960_j(), var13);
          ((TileEntitySkull) var12).func_82116_a(var11);
          ((BlockSkull) Block.field_82512_cj)
              .func_82529_a(
                  p_77648_3_, p_77648_4_, p_77648_5_, p_77648_6_, (TileEntitySkull) var12);
        }

        --p_77648_1_.field_77994_a;
        return true;
      }
    }
  }