I just came up with an idea of a minigame... But I need to to edit the ai of a Wither as shown: The Wither stays in the same place and takes no knock back. Players on the same team as the Wither cannot damage it. The Wither attacks enemies and grants potion buffs to players on the same team when they are close to it. I also want to trigger an action from the plugin when the Wither dies. Any idea how to do that?
If you just started developing plugins I DEFINITELY do not recommend doing this. Nobody even has a functional wither AI. I recommend starting with easy plugins.
Tbh, since you dont want it to move it all, just spawn a wither at the beginning of each game. But, I dont think pocketmine even has withers yet.
Is it correct to say that? PocketMine doesn't have wither implementation, but you surely can spawn it.
I should reword that, if you can spawn the entity at the beginning of each game with code, it shouldnt move since PM hasn't implemented the ai code yet. But, I don't think it's possible to spawn it with code yet, don't quote me though.
You can implement fully working mobs even in plugin. You dont need to implement it to pocketmine directly
https://github.com/milk0417/PureEntities/tree/master/src/milk/pureentities/entity You can find an abundance of code for what you are looking for here
PHP: foreach($this->teamblue as $player){ //$this->teamblue is team blue players if($teambluewither->distance($player) <= $distance){ //$distance will be the amount of blocks the players need to be in to get the buffs //your code }}
Let's start off here. To use the Wither, you've to create a new class for it, as it doesn't seem that there is currently one. This class has to extend Monster, as it is hostile and default behavior and other things for hostile mobs may be added in the future. Now that you have a Wither class, how do we define custom behavior on attack? We can see how PrimedTNT does it, as it is another entity that is invulnerable. It simply overrides Living::attack(), and doesn't call the parent function (unless it's being damaged by the void). We then override this in Wither and get the player from EntityDamageEvent. The rest for this part is up to you. Now, how do we define custom behavior for our Wither when players are close? We probably want to do this on every tick (or so), so we can override Entity:nUpdate(). To get nearby entities in a Level, you can use Level::getNearbyEntities(). The rest is left as an exercise to the reader.
youre right. shouldve look closely this is plugin development section, here you ask for code and we will give you code, you can clearly see he said he wants to know how to get nearby players and buff them/attack them. that doesnt answears on his full question, but that gives him a little idea of how to make it
I haven't seen anyone learning how to spawn entities for a long time. For so many months I just see people copying the code for spawning arrows everywhere.
If you are just looking for code, request a plugin. Code isn't the armor you mix in a crafting table put on your Steve to make it stronger. Code is part of the plugin, something that cannot be alienated from the rest of the plugin. If you want code, you are asking for the whole plugin.