Search in sources :

Example 1 with EntityGrapple

use of micdoodle8.mods.galacticraft.planets.asteroids.entities.EntityGrapple in project Galacticraft by micdoodle8.

the class PacketSimpleAsteroids method handleClientSide.

@SideOnly(Side.CLIENT)
@Override
public void handleClientSide(EntityPlayer player) {
    EntityPlayerSP playerBaseClient = null;
    if (player instanceof EntityPlayerSP) {
        playerBaseClient = (EntityPlayerSP) player;
    }
    TileEntity tile;
    switch(this.type) {
        case C_TELEPAD_SEND:
            Entity entity = playerBaseClient.worldObj.getEntityByID((Integer) this.data.get(1));
            if (entity != null && entity instanceof EntityLivingBase) {
                BlockVec3 pos = (BlockVec3) this.data.get(0);
                entity.setPosition(pos.x + 0.5, pos.y + 2.2, pos.z + 0.5);
            }
            break;
        case C_UPDATE_GRAPPLE_POS:
            entity = playerBaseClient.worldObj.getEntityByID((Integer) this.data.get(0));
            if (entity != null && entity instanceof EntityGrapple) {
                Vector3 vec = (Vector3) this.data.get(1);
                entity.setPosition(vec.x, vec.y, vec.z);
            }
            break;
        default:
            break;
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) Entity(net.minecraft.entity.Entity) TileEntity(net.minecraft.tileentity.TileEntity) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityGrapple(micdoodle8.mods.galacticraft.planets.asteroids.entities.EntityGrapple) Vector3(micdoodle8.mods.galacticraft.api.vector.Vector3) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) BlockVec3(micdoodle8.mods.galacticraft.api.vector.BlockVec3) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 2 with EntityGrapple

use of micdoodle8.mods.galacticraft.planets.asteroids.entities.EntityGrapple in project Galacticraft by micdoodle8.

the class ItemGrappleHook method onPlayerStoppedUsing.

@Override
public void onPlayerStoppedUsing(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer, int par4) {
    boolean flag = par3EntityPlayer.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, par1ItemStack) > 0;
    if (flag || par3EntityPlayer.inventory.hasItem(Items.string)) {
        EntityGrapple grapple = new EntityGrapple(par2World, par3EntityPlayer, 2.0F);
        par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 1.0F, 1.0F / (Item.itemRand.nextFloat() * 0.4F + 1.2F) + 0.5F);
        if (!par2World.isRemote) {
            par2World.spawnEntityInWorld(grapple);
        }
        par1ItemStack.damageItem(1, par3EntityPlayer);
        grapple.canBePickedUp = par3EntityPlayer.capabilities.isCreativeMode ? 2 : 1;
        if (!par3EntityPlayer.capabilities.isCreativeMode) {
            par3EntityPlayer.inventory.consumeInventoryItem(Items.string);
        }
    } else if (par2World.isRemote) {
        par3EntityPlayer.addChatMessage(new ChatComponentText(GCCoreUtil.translate("gui.message.grapple.fail")));
    }
}
Also used : EntityGrapple(micdoodle8.mods.galacticraft.planets.asteroids.entities.EntityGrapple) ChatComponentText(net.minecraft.util.ChatComponentText)

Aggregations

EntityGrapple (micdoodle8.mods.galacticraft.planets.asteroids.entities.EntityGrapple)2 BlockVec3 (micdoodle8.mods.galacticraft.api.vector.BlockVec3)1 Vector3 (micdoodle8.mods.galacticraft.api.vector.Vector3)1 EntityPlayerSP (net.minecraft.client.entity.EntityPlayerSP)1 Entity (net.minecraft.entity.Entity)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 TileEntity (net.minecraft.tileentity.TileEntity)1 ChatComponentText (net.minecraft.util.ChatComponentText)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1