question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

pollProjectileHits

See original GitHub issue

I had to use a old version of mcpi the other night. trying to use pollProjectileHits but an error that states the BlockEvent in minecraft.py file are out of the arrays range is prompted every time my arrow hits a block. Sorry, I don’t have what the error specifically says atm. Note the old mcpi has no problem with my code.

def pollProjectileHits(self):
        """Only triggered by projectiles => [BlockEvent]"""
        s = self.conn.sendReceive(b"player.events.projectile.hits")
        events = [e for e in s.split("|") if e]
        results = []
        for e in events:
            info = e.split(",")
            results.append(ProjectileEvent.Hit(
                int(info[0]), 
                int(info[1]), 
                int(info[2]), 
                int(info[3]), 
                info[4],
                info[5])<------- this is where the error is highlighted.
        return results

this is a sample of my code.

def amenotejikara(): #Teleporting with arrow shots
    for blockhit in mc.player.pollProjectileHits():
        pos = blockhit.pos
        teleport = mc.player.setPos(pos.x, pos.y, pos.z)

edited to include code blocks

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
martinohanloncommented, Jun 29, 2020

Tested with RaspberryJuice 1.12.1 + mcpi1.2 - I cant find any issues.

image

I am also confused by your comment

I had to use a old version of mcpi the other night.

pollProjectileHits didnt exist in any version of mcpi before version 1.2

Closing as unable to reproduce, feel free to reopen if you can provide additional information.

0reactions
PoSihDuncommented, Jun 30, 2020

IMG_20200629_213337

The picture above is using a version of mcpi saved to my google drive from a while back, it runs the code just fine

IMG_20200629_214337 IMG_20200629_213514 IMG_20200629_213525

This is what happens when I try and run the code with version 1.2.

Thanks for your help.

Read more comments on GitHub >

github_iconTop Results From Across the Web

RaspberryJuice/README.md at master - GitHub
pollProjectileHits - get events back of arrow hit for the player; player.pollBlockHits - get block hits for the player; player.
Read more >
RaspberryJuice | SpigotMC - High Performance Minecraft
pollProjectileHits - get events back of arrow hit for the player; player.pollBlockHits - get block hits for the player; player.
Read more >
mcScripts2(jutsu) [Minecraft: Java Edition] [Config Scripts]
pollProjectileHits (): pos = blockhit.pos teleport = mc.player.setPos(pos.x, pos.y, pos.z) def fireAShot(): #Fire arrows for blockhit in mc.player.
Read more >
Custom Commands for Minecraft using python and mcpi
I've just started with mcpi and I want to have custom commands to capture chat posts starting with / . How can I...
Read more >
TeachCraft: آموزش برنامه‌نویسی پایتون از طریق بازی ماینکرفت
pollProjectileHits (): if active_spell == "teleport": mc.player.setPos(blockhit.pos.x, blockhit.pos.y, blockhit.pos.z) elif active_spell == "lavapool": ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found