Example #1
0
 public override bool blockActivated(World world, int i, int j, int k, EntityPlayer entityplayer)
 {
     int l = world.getBlockMetadata(i, j, k);
     int i1 = (l & 0xc) >> 2;
     i1 = i1 + 1 << 2 & 0xc;
     world.setBlockMetadataWithNotify(i, j, k, i1 | l & 3);
     return true;
 }
Example #2
0
 public virtual void onCraftGuiClosed(EntityPlayer entityplayer)
 {
     InventoryPlayer inventoryplayer = entityplayer.inventory;
     if (inventoryplayer.getItemStack() != null)
     {
         entityplayer.dropPlayerItem(inventoryplayer.getItemStack());
         inventoryplayer.setItemStack(null);
     }
 }
Example #3
0
 public virtual bool canInteractWith(EntityPlayer entityplayer)
 {
     if (worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) != this)
     {
         return false;
     }
     return entityplayer.getDistanceSq(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D) <=
            64D;
 }
Example #4
0
 public override bool blockActivated(World world, int i, int j, int k, EntityPlayer entityplayer)
 {
     object obj = world.getBlockTileEntity(i, j, k);
     if (world.isBlockOpaqueCube(i, j + 1, k))
     {
         return true;
     }
     if (world.getBlockId(i - 1, j, k) == blockID && world.isBlockOpaqueCube(i - 1, j + 1, k))
     {
         return true;
     }
     if (world.getBlockId(i + 1, j, k) == blockID && world.isBlockOpaqueCube(i + 1, j + 1, k))
     {
         return true;
     }
     if (world.getBlockId(i, j, k - 1) == blockID && world.isBlockOpaqueCube(i, j + 1, k - 1))
     {
         return true;
     }
     if (world.getBlockId(i, j, k + 1) == blockID && world.isBlockOpaqueCube(i, j + 1, k + 1))
     {
         return true;
     }
     if (world.getBlockId(i - 1, j, k) == blockID)
     {
         obj = new InventoryLargeChest("Large chest", (TileEntityChest) world.getBlockTileEntity(i - 1, j, k),
                                       ((IInventory) (obj)));
     }
     if (world.getBlockId(i + 1, j, k) == blockID)
     {
         obj = new InventoryLargeChest("Large chest", ((IInventory) (obj)),
                                       (TileEntityChest) world.getBlockTileEntity(i + 1, j, k));
     }
     if (world.getBlockId(i, j, k - 1) == blockID)
     {
         obj = new InventoryLargeChest("Large chest", (TileEntityChest) world.getBlockTileEntity(i, j, k - 1),
                                       ((IInventory) (obj)));
     }
     if (world.getBlockId(i, j, k + 1) == blockID)
     {
         obj = new InventoryLargeChest("Large chest", ((IInventory) (obj)),
                                       (TileEntityChest) world.getBlockTileEntity(i, j, k + 1));
     }
     if (world.singleplayerWorld)
     {
         return true;
     }
     else
     {
         entityplayer.displayGUIChest(((IInventory) (obj)));
         return true;
     }
 }
 public Packet20NamedEntitySpawn(EntityPlayer entityplayer)
 {
     entityId = entityplayer.entityId;
     name = entityplayer.username;
     xPosition = MathHelper.floor_double(entityplayer.posX*32D);
     yPosition = MathHelper.floor_double(entityplayer.posY*32D);
     zPosition = MathHelper.floor_double(entityplayer.posZ*32D);
     rotation = (byte) (int) ((entityplayer.rotationYaw*256F)/360F);
     pitch = (byte) (int) ((entityplayer.rotationPitch*256F)/360F);
     ItemStack itemstack = entityplayer.inventory.getCurrentItem();
     currentItem = itemstack != null ? itemstack.itemID : 0;
 }
Example #6
0
 public override void onBlockClicked(World world, int i, int j, int k, EntityPlayer entityplayer)
 {
     if (world.singleplayerWorld)
     {
         return;
     }
     else
     {
         var tileentitynote = (TileEntityNote) world.getBlockTileEntity(i, j, k);
         tileentitynote.triggerNote(world, i, j, k);
         return;
     }
 }
Example #7
0
 public override bool blockActivated(World world, int i, int j, int k, EntityPlayer entityplayer)
 {
     if (world.singleplayerWorld)
     {
         return true;
     }
     else
     {
         var tileentitynote = (TileEntityNote) world.getBlockTileEntity(i, j, k);
         tileentitynote.changePitch();
         tileentitynote.triggerNote(world, i, j, k);
         return true;
     }
 }
Example #8
0
 public override void onCollideWithPlayer(EntityPlayer entityplayer)
 {
     if (worldObj.singleplayerWorld)
     {
         return;
     }
     int i = item.stackSize;
     if (delayBeforeCanPickup == 0 && entityplayer.inventory.addItemStackToInventory(item))
     {
         worldObj.playSoundAtEntity(this, "random.pop", 0.2F,
                                    ((rand.nextFloat() - rand.nextFloat())*0.7F + 1.0F)*2.0F);
         entityplayer.onItemPickup(this, i);
         setEntityDead();
     }
 }
Example #9
0
 public override void onCollideWithPlayer(EntityPlayer entityplayer)
 {
     if (worldObj.singleplayerWorld)
     {
         return;
     }
     if (inGround && owner == entityplayer && arrowShake <= 0 &&
         entityplayer.inventory.addItemStackToInventory(new ItemStack(Item.arrow, 1)))
     {
         worldObj.playSoundAtEntity(this, "random.pop", 0.2F,
                                    ((rand.nextFloat() - rand.nextFloat())*0.7F + 1.0F)*2.0F);
         entityplayer.onItemPickup(this, 1);
         setEntityDead();
     }
 }
Example #10
0
 public override bool blockActivated(World world, int i, int j, int k, EntityPlayer entityplayer)
 {
     int l = world.getBlockMetadata(i, j, k);
     int i1 = l & 7;
     int j1 = 8 - (l & 8);
     if (j1 == 0)
     {
         return true;
     }
     world.setBlockMetadataWithNotify(i, j, k, i1 + j1);
     world.markBlocksDirty(i, j, k, i, j, k);
     world.playSoundEffect(i + 0.5D, j + 0.5D, k + 0.5D, "random.click", 0.3F, 0.6F);
     world.notifyBlocksOfNeighborChange(i, j, k, blockID);
     if (i1 == 1)
     {
         world.notifyBlocksOfNeighborChange(i - 1, j, k, blockID);
     }
     else if (i1 == 2)
     {
         world.notifyBlocksOfNeighborChange(i + 1, j, k, blockID);
     }
     else if (i1 == 3)
     {
         world.notifyBlocksOfNeighborChange(i, j, k - 1, blockID);
     }
     else if (i1 == 4)
     {
         world.notifyBlocksOfNeighborChange(i, j, k + 1, blockID);
     }
     else
     {
         world.notifyBlocksOfNeighborChange(i, j - 1, k, blockID);
     }
     world.func_22074_c(i, j, k, blockID, tickRate());
     return true;
 }
Example #11
0
 public override void onBlockClicked(World world, int i, int j, int k, EntityPlayer entityplayer)
 {
     func_321_g(world, i, j, k);
     base.onBlockClicked(world, i, j, k, entityplayer);
 }
Example #12
0
 public ItemStack useItemRightClick(World world, EntityPlayer entityplayer)
 {
     return getItem().onItemRightClick(this, world, entityplayer);
 }
Example #13
0
 public void func_577_a(EntityPlayer entityplayer)
 {
 }
Example #14
0
 public override bool blockActivated(World world, int i, int j, int k, EntityPlayer entityplayer)
 {
     func_21030_c(world, i, j, k, entityplayer);
     return true;
 }
Example #15
0
 public virtual void onCollideWithPlayer(EntityPlayer entityplayer)
 {
 }
Example #16
0
 public override bool interact(EntityPlayer entityplayer)
 {
     if (minecartType == 0)
     {
         if (riddenByEntity != null && (riddenByEntity is EntityPlayer) && riddenByEntity != entityplayer)
         {
             return true;
         }
         if (!worldObj.singleplayerWorld)
         {
             entityplayer.mountEntity(this);
         }
     }
     else if (minecartType == 1)
     {
         if (!worldObj.singleplayerWorld)
         {
             entityplayer.displayGUIChest(this);
         }
     }
     else if (minecartType == 2)
     {
         ItemStack itemstack = entityplayer.inventory.getCurrentItem();
         if (itemstack != null && itemstack.itemID == Item.coal.shiftedIndex)
         {
             if (--itemstack.stackSize == 0)
             {
                 entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, null);
             }
             fuel += 1200;
         }
         pushX = posX - entityplayer.posX;
         pushZ = posZ - entityplayer.posZ;
     }
     return true;
 }
Example #17
0
 public virtual bool blockActivated(World world, int i, int j, int k, EntityPlayer entityplayer)
 {
     return false;
 }
Example #18
0
 public override void onBlockClicked(World world, int i, int j, int k, EntityPlayer entityplayer)
 {
     blockActivated(world, i, j, k, entityplayer);
 }
Example #19
0
 public override void onBlockClicked(World world, int i, int j, int k, EntityPlayer entityplayer)
 {
     blockActivated(world, i, j, k, entityplayer);
 }
Example #20
0
 public virtual bool blockActivated(World world, int i, int j, int k, EntityPlayer entityplayer)
 {
     return(false);
 }
Example #21
0
        public ItemStack placeItem(int i, int j, EntityPlayer entityplayer)
        {
            ItemStack itemstack = null;

            if (j == 0 || j == 1)
            {
                InventoryPlayer inventoryplayer = entityplayer.inventory;
                if (i == -999)
                {
                    if (inventoryplayer.getItemStack() != null && i == -999)
                    {
                        if (j == 0)
                        {
                            entityplayer.dropPlayerItem(inventoryplayer.getItemStack());
                            inventoryplayer.setItemStack(null);
                        }
                        if (j == 1)
                        {
                            entityplayer.dropPlayerItem(inventoryplayer.getItemStack().splitStack(1));
                            if (inventoryplayer.getItemStack().stackSize == 0)
                            {
                                inventoryplayer.setItemStack(null);
                            }
                        }
                    }
                }
                else
                {
                    var slot = (Slot)inventorySlots.get(i);
                    if (slot != null)
                    {
                        slot.onSlotChanged();
                        ItemStack itemstack1 = slot.getStack();
                        ItemStack itemstack2 = inventoryplayer.getItemStack();
                        if (itemstack1 != null)
                        {
                            itemstack = itemstack1.copy();
                        }
                        if (itemstack1 == null)
                        {
                            if (itemstack2 != null && slot.isItemValid(itemstack2))
                            {
                                int k = j != 0 ? 1 : itemstack2.stackSize;
                                if (k > slot.getSlotStackLimit())
                                {
                                    k = slot.getSlotStackLimit();
                                }
                                slot.putStack(itemstack2.splitStack(k));
                                if (itemstack2.stackSize == 0)
                                {
                                    inventoryplayer.setItemStack(null);
                                }
                            }
                        }
                        else if (itemstack2 == null)
                        {
                            int l = j != 0 ? (itemstack1.stackSize + 1) / 2 : itemstack1.stackSize;
                            inventoryplayer.setItemStack(slot.decrStackSize(l));
                            if (itemstack1.stackSize == 0)
                            {
                                slot.putStack(null);
                            }
                            slot.onPickupFromSlot();
                        }
                        else if (slot.isItemValid(itemstack2))
                        {
                            if (itemstack1.itemID != itemstack2.itemID ||
                                itemstack1.getHasSubtypes() && itemstack1.getItemDamage() != itemstack2.getItemDamage())
                            {
                                if (itemstack2.stackSize <= slot.getSlotStackLimit())
                                {
                                    ItemStack itemstack3 = itemstack1;
                                    slot.putStack(itemstack2);
                                    inventoryplayer.setItemStack(itemstack3);
                                }
                            }
                            else
                            {
                                int i1 = j != 0 ? 1 : itemstack2.stackSize;
                                if (i1 > slot.getSlotStackLimit() - itemstack1.stackSize)
                                {
                                    i1 = slot.getSlotStackLimit() - itemstack1.stackSize;
                                }
                                if (i1 > itemstack2.getMaxStackSize() - itemstack1.stackSize)
                                {
                                    i1 = itemstack2.getMaxStackSize() - itemstack1.stackSize;
                                }
                                itemstack2.splitStack(i1);
                                if (itemstack2.stackSize == 0)
                                {
                                    inventoryplayer.setItemStack(null);
                                }
                                itemstack1.stackSize += i1;
                            }
                        }
                        else if (itemstack1.itemID == itemstack2.itemID && itemstack2.getMaxStackSize() > 1 &&
                                 (!itemstack1.getHasSubtypes() ||
                                  itemstack1.getItemDamage() == itemstack2.getItemDamage()))
                        {
                            int j1 = itemstack1.stackSize;
                            if (j1 > 0 && j1 + itemstack2.stackSize <= itemstack2.getMaxStackSize())
                            {
                                itemstack2.stackSize += j1;
                                itemstack1.splitStack(j1);
                                if (itemstack1.stackSize == 0)
                                {
                                    slot.putStack(null);
                                }
                                slot.onPickupFromSlot();
                            }
                        }
                    }
                }
            }
            return(itemstack);
        }
Example #22
0
 public abstract bool canInteractWith(EntityPlayer entityplayer);
Example #23
0
 public bool getCanCraft(EntityPlayer entityplayer)
 {
     return(!field_20131_b.contains(entityplayer));
 }
Example #24
0
 public virtual bool canInteractWith(EntityPlayer entityplayer)
 {
     if (isDead)
     {
         return false;
     }
     return entityplayer.getDistanceSqToEntity(this) <= 64D;
 }
Example #25
0
 public virtual float blockStrength(EntityPlayer entityplayer)
 {
     if (blockHardness < 0.0F)
     {
         return 0.0F;
     }
     if (!entityplayer.canHarvestBlock(this))
     {
         return 1.0F/blockHardness/100F;
     }
     else
     {
         return entityplayer.getCurrentPlayerStrVsBlock(this)/blockHardness/30F;
     }
 }
Example #26
0
 public virtual bool interact(EntityPlayer entityplayer)
 {
     return false;
 }
Example #27
0
 public virtual void onBlockClicked(World world, int i, int j, int k, EntityPlayer entityplayer)
 {
 }
Example #28
0
 private void func_21030_c(World world, int i, int j, int k, EntityPlayer entityplayer)
 {
     if (entityplayer.health < 20)
     {
         entityplayer.heal(3);
         int l = world.getBlockMetadata(i, j, k) + 1;
         if (l >= 6)
         {
             world.setBlockWithNotify(i, j, k, 0);
         }
         else
         {
             world.setBlockMetadataWithNotify(i, j, k, l);
             world.markBlockAsNeedsUpdate(i, j, k);
         }
     }
 }
Example #29
0
 public override ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer)
 {
     float f = 1.0F;
     float f1 = entityplayer.prevRotationPitch + (entityplayer.rotationPitch - entityplayer.prevRotationPitch)*f;
     float f2 = entityplayer.prevRotationYaw + (entityplayer.rotationYaw - entityplayer.prevRotationYaw)*f;
     double d = entityplayer.prevPosX + (entityplayer.posX - entityplayer.prevPosX)*f;
     double d1 = (entityplayer.prevPosY + (entityplayer.posY - entityplayer.prevPosY)*f +
                  1.6200000000000001D) - entityplayer.yOffset;
     double d2 = entityplayer.prevPosZ + (entityplayer.posZ - entityplayer.prevPosZ)*f;
     Vec3D vec3d = Vec3D.createVector(d, d1, d2);
     float f3 = MathHelper.cos(-f2*0.01745329F - 3.141593F);
     float f4 = MathHelper.sin(-f2*0.01745329F - 3.141593F);
     float f5 = -MathHelper.cos(-f1*0.01745329F);
     float f6 = MathHelper.sin(-f1*0.01745329F);
     float f7 = f4*f5;
     float f8 = f6;
     float f9 = f3*f5;
     double d3 = 5D;
     Vec3D vec3d1 = vec3d.addVector(f7*d3, f8*d3, f9*d3);
     MovingObjectPosition movingobjectposition = world.rayTraceBlocks_do(vec3d, vec3d1, isFull == 0);
     if (movingobjectposition == null)
     {
         return itemstack;
     }
     if (movingobjectposition.typeOfHit == EnumMovingObjectType.TILE)
     {
         int i = movingobjectposition.blockX;
         int j = movingobjectposition.blockY;
         int k = movingobjectposition.blockZ;
         if (!world.canMineBlock(entityplayer, i, j, k))
         {
             return itemstack;
         }
         if (isFull == 0)
         {
             if (world.getBlockMaterial(i, j, k) == Material.water && world.getBlockMetadata(i, j, k) == 0)
             {
                 world.setBlockWithNotify(i, j, k, 0);
                 return new ItemStack(bucketWater);
             }
             if (world.getBlockMaterial(i, j, k) == Material.lava && world.getBlockMetadata(i, j, k) == 0)
             {
                 world.setBlockWithNotify(i, j, k, 0);
                 return new ItemStack(bucketLava);
             }
         }
         else
         {
             if (isFull < 0)
             {
                 return new ItemStack(bucketEmpty);
             }
             if (movingobjectposition.sideHit == 0)
             {
                 j--;
             }
             if (movingobjectposition.sideHit == 1)
             {
                 j++;
             }
             if (movingobjectposition.sideHit == 2)
             {
                 k--;
             }
             if (movingobjectposition.sideHit == 3)
             {
                 k++;
             }
             if (movingobjectposition.sideHit == 4)
             {
                 i--;
             }
             if (movingobjectposition.sideHit == 5)
             {
                 i++;
             }
             if (world.isAirBlock(i, j, k) || !world.getBlockMaterial(i, j, k).isSolid())
             {
                 if (world.worldProvider.isHellWorld && isFull == Block.waterStill.blockID)
                 {
                     world.playSoundEffect(d + 0.5D, d1 + 0.5D, d2 + 0.5D, "random.fizz", 0.5F,
                                           2.6F + (world.rand.nextFloat() - world.rand.nextFloat())*0.8F);
                     for (int l = 0; l < 8; l++)
                     {
                         world.spawnParticle("largesmoke", i + Math.random(), j + Math.random(),
                                             k + Math.random(), 0.0D, 0.0D, 0.0D);
                     }
                 }
                 else
                 {
                     world.setBlockAndMetadataWithNotify(i, j, k, isFull, 0);
                 }
                 return new ItemStack(bucketEmpty);
             }
         }
     }
     else if (isFull == 0 && (movingobjectposition.entityHit is EntityCow))
     {
         return new ItemStack(bucketMilk);
     }
     return itemstack;
 }
Example #30
0
 public override void onBlockClicked(World world, int i, int j, int k, EntityPlayer entityplayer)
 {
     func_21030_c(world, i, j, k, entityplayer);
 }
Example #31
0
 public override bool blockActivated(World world, int i, int j, int k, EntityPlayer entityplayer)
 {
     func_321_g(world, i, j, k);
     return(base.blockActivated(world, i, j, k, entityplayer));
 }
Example #32
0
 public bool useItem(EntityPlayer entityplayer, World world, int i, int j, int k, int l)
 {
     return getItem().onItemUse(this, entityplayer, world, i, j, k, l);
 }
Example #33
0
        public virtual void updatePlayerActionState()
        {
            age++;
            EntityPlayer entityplayer = worldObj.getClosestPlayerToEntity(this, -1D);

            if (entityplayer != null)
            {
                double d  = ((entityplayer)).posX - posX;
                double d1 = ((entityplayer)).posY - posY;
                double d2 = ((entityplayer)).posZ - posZ;
                double d3 = d * d + d1 * d1 + d2 * d2;
                if (d3 > 16384D)
                {
                    setEntityDead();
                }
                if (age > 600 && rand.nextInt(800) == 0)
                {
                    if (d3 < 1024D)
                    {
                        age = 0;
                    }
                    else
                    {
                        setEntityDead();
                    }
                }
            }
            moveStrafing = 0.0F;
            moveForward  = 0.0F;
            float f = 8F;

            if (rand.nextFloat() < 0.02F)
            {
                EntityPlayer entityplayer1 = worldObj.getClosestPlayerToEntity(this, f);
                if (entityplayer1 != null)
                {
                    currentTarget         = entityplayer1;
                    numTicksToChaseTarget = 10 + rand.nextInt(20);
                }
                else
                {
                    randomYawVelocity = (rand.nextFloat() - 0.5F) * 20F;
                }
            }
            if (currentTarget != null)
            {
                faceEntity(currentTarget, 10F);
                if (numTicksToChaseTarget-- <= 0 || currentTarget.isDead ||
                    currentTarget.getDistanceSqToEntity(this) > (f * f))
                {
                    currentTarget = null;
                }
            }
            else
            {
                if (rand.nextFloat() < 0.05F)
                {
                    randomYawVelocity = (rand.nextFloat() - 0.5F) * 20F;
                }
                rotationYaw  += randomYawVelocity;
                rotationPitch = defaultPitch;
            }
            bool flag  = handleWaterMovement();
            bool flag1 = handleLavaMovement();

            if (flag || flag1)
            {
                isJumping = rand.nextFloat() < 0.8F;
            }
        }
Example #34
0
 public override bool blockActivated(World world, int i, int j, int k, EntityPlayer entityplayer)
 {
     func_321_g(world, i, j, k);
     return base.blockActivated(world, i, j, k, entityplayer);
 }
Example #35
0
 public virtual void readPlayerData(EntityPlayer entityplayer)
 {
     try
     {
         var file = new File(worldFile,
                             (new StringBuilder()).append(entityplayer.username).append(".dat").toString());
         if (file.exists())
         {
             NBTTagCompound nbttagcompound = CompressedStreamTools.func_770_a(new FileInputStream(file));
             if (nbttagcompound != null)
             {
                 entityplayer.readFromNBT(nbttagcompound);
             }
         }
     }
     catch (Exception)
     {
         logger.warning(
             (new StringBuilder()).append("Failed to load player data for ").append(entityplayer.username).
                 toString());
     }
 }
Example #36
0
 public override bool interact(EntityPlayer entityplayer)
 {
     if (riddenByEntity != null && (riddenByEntity is EntityPlayer) && riddenByEntity != entityplayer)
     {
         return true;
     }
     if (!worldObj.singleplayerWorld)
     {
         entityplayer.mountEntity(this);
     }
     return true;
 }
Example #37
0
 public virtual void writePlayerData(EntityPlayer entityplayer)
 {
     try
     {
         var nbttagcompound = new NBTTagCompound();
         entityplayer.writeToNBT(nbttagcompound);
         var file = new File(worldFile, "_tmp_.dat");
         var file1 = new File(worldFile,
                              (new StringBuilder()).append(entityplayer.username).append(".dat").toString());
         CompressedStreamTools.writeGzippedCompoundToOutputStream(nbttagcompound, new FileOutputStream(file));
         if (file1.exists())
         {
             file1.delete();
         }
         file.renameTo(file1);
     }
     catch (Exception)
     {
         logger.warning(
             (new StringBuilder()).append("Failed to save player data for ").append(entityplayer.username).
                 toString());
     }
 }
Example #38
0
 public override void onBlockClicked(World world, int i, int j, int k, EntityPlayer entityplayer)
 {
     func_321_g(world, i, j, k);
     base.onBlockClicked(world, i, j, k, entityplayer);
 }
Example #39
0
 public virtual void onBlockClicked(World world, int i, int j, int k, EntityPlayer entityplayer)
 {
 }