Ejemplo n.º 1
0
 @Override
 public boolean renderWorldBlock(
     IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
   if (((BaseBlock) block).data instanceof BRodPart) {
     return this.renderRod1T(
         world, x, y, z, block, WorldUtil.getBlockFacing(world, x, y, z) ^ 1, renderer);
   }
   return this.renderRod(
       world, x, y, z, block, WorldUtil.getBlockFacing(world, x, y, z), renderer);
 }
Ejemplo n.º 2
0
  @Override
  public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) {

    if (entity instanceof EntityLivingBase) {
      MovingObjectPosition movingobjectposition = new MovingObjectPosition(entity);

      // SAVE ENTITY NBT //
      NBTTagCompound nbt = new NBTTagCompound();
      if (movingobjectposition.entityHit instanceof EntityLivingBase) {
        ((EntityLivingBase) movingobjectposition.entityHit).writeEntityToNBT(nbt);
      }

      // CAUSE DAMAGE //

      if (player.capabilities.isCreativeMode) {
        movingobjectposition.entityHit.attackEntityFrom(
            DamageSource.causePlayerDamage(player), (float) 99999F);
      } else {
        movingobjectposition.entityHit.attackEntityFrom(
            DamageSource.causePlayerDamage(player), (float) 2F);
        stack.stackSize--;
        if (stack.stackSize <= 0)
          player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
      }

      // PETRIFICATION //
      EntityLivingBase target = (EntityLivingBase) entity;

      if (target.getHealth() <= 0) {
        World world = target.worldObj;
        int x = (int) target.posX;
        int y = (int) target.posY;
        int z = (int) target.posZ;

        WorldUtil.setBlock(world, x, y, z, BlockData.statue.block);

        TileStatue tile = (TileStatue) WorldUtil.getPTile(world, x, y, z);

        EntityLivingBase statueEntity = null;
        Class oclass = target.getClass();

        if (oclass != null) {
          try {
            statueEntity =
                (EntityLivingBase)
                    oclass
                        .getConstructor(new Class[] {World.class})
                        .newInstance(new Object[] {player.worldObj});
          } catch (Exception exception) {
            exception.printStackTrace();
          }
        }

        if (statueEntity != null) {
          statueEntity.readEntityFromNBT(nbt);
          tile.setEntity((EntityLivingBase) statueEntity);

          tile.setAngle((int) (-target.rotationYaw));
          if (!world.isRemote && ConfigData.statueSmoke)
            PacketHandler.sendToAllInDimension(
                new SmokePacket(x, y, z, player.dimension), player.dimension);
        } else System.out.println("Entity was null!");
      }

      return true;
    }

    return false;
  }