How to let a player block (1.8.8) - plugins

I tried to make the player block (If you rightclick with a sword you block)
and I had the idea to use
player.setBlocking(true);
But that does'nt exist. There is only a method to check if a player is blocking but I could'nt find anything to set the Player blocking.
Method to check if Blocking:
player.isBlocking();

You can't force player to "block" (use item), check this for more information about Minecraft protocols.
but you can try something with
Bukkit.getPluginManager().callEvent(new ...Event(...));
But in this case only result of an action will be sent to user.

Related

Anylogic detect that agent stopped on conveyor

is there any easy way to detect that agent stopped on a roller conveyor because there are other agents ahead? I tried to use dynamic variable and conditional event but it is consuming too much performence. I donĀ“t want to go for dynamically checking condition (with cyclic event) because I have some bad experience with it.
Thanks!
Try this:
Create a LinkedList<YourAgentType> agentsOnConveyor.
Whenever an agent enters the conveyor, call agentsOnConveyor.addLast(agent). When it leaves, call agentsOnConveyor.removeFirst(agent).
Now you have a linked representation of the agents on the conveyor.
Last, you use the "on stopped" field in the conveyor and pass the message "upstream" through the linked list, i.e. use a for-loop from the first to the last entry and send them a msg "conveyor stopped".
You may still need to check if the individual agent is moving itself or has also stopped, but it might put you on a working path

Unity - Navmesh event on navigation end

Is there a way to raise a flag on the Navmesh navigation end, or to use a callback when it finish?
I want to run a function when my objection reach to the desire position, I can check on every frame update if the navigation has finished but I want a more elegant and efficient solution.
Thanks.
It depends what you mean by "ends", if you want to know when a path is no longer available for the NavAgent, you can use pathStatus, for example you could write:
if(myNavAgent.pathStatus != NavMeshPathStatus.PathComplete) {
// Do stuff
}
If you me reaching a location such as a "waypoint" you can use myNavAgent.remainingDistance then check if it is less than a certain value.
Here's the unity NavAgent scriptingAPI doc link: https://docs.unity3d.com/ScriptReference/AI.NavMeshAgent.html
If this doesn't work, let me know!
I have Thought the same question and i couldn't find a callback, However i managed to solve with triggers. For example if my agent goes point a, i put trigger that position and when my agent touches it i stopped agent.

Gamesparks: Remove player from pending match

I'm using gamesparks and I need to disconnect player from pendingMatch, if the player is waiting for another player to connect very long time. Found this: match.removePlayersById(playerIdsToRemove) but I need to have matchID, to get match. but don't know how.
Please help me to remove player from match.
thank, you
Use Spark.getMultiplayer().cancelMatchmaking(player, matchShortCode, matchGroup); matchShortCode you can get from SparkData and in case you don't have matchGroup use empty string.

How would I be of making a script that shows subtitles when a touch function triggers?

How do I make a script if somebody touched a brick and then maybe a GUI then shows subtitles for like a few seconds and goes the downside of your screen? (like credits after a movie)
I know the first part of creating this but I do not know the GUI part. For the first part, I think you should do something like this...
local Part = script.Parent -- This would define the part that is to be touched.
function onTouch(Brick) -- Starts the onTouch function which sends us "Brick", the triggering object.
local Player = Brick.Parent:findFirstChild("Humanoid") -- Finds Humanoid in Brick.
if (Player ~= nil) then -- Checks if the player is a real Player.
print("Hello World"")
end
end
Replace the print("Hello World!") line with the code from the GUI if you know it.
Regards, Shay!

Proper transition between SpriteKit Animations

I have an idle player animation and I want to do a smooth transition between some animations. The idle animation is the default one and from that transition I want to be able to switch to another state(let's say fight) and then back to idle. The code for the idle character animation is currently like :
self.addChild(playerAnimation)
playerAnimation.runAction(SKAction.repeatActionForever(
SKAction.animateWithTextures(playerAnimationManager.idleManAnimation.textureArray, timePerFrame: 0.1)))
Now, this is scheduled to go on forever for now, but I would need to intercept it and add a new animation on top of that (which is the same character, in a new state). I was thinking that I should stop the idle animation, switch to the new one and then back to idle when finished but I am not convinced that this is the best way of chaining animations and I haven't really found a good resource explaining how to go about it.
Any suggestions ? Thanks !
Depending on how short your texture array is, you might be able to do this.
I will try to explain without code seeing how I use objective C and you use Swift
First make a property or variable that can be called by any subroutine in this class file. It should be Boolean and should be set to NO. You could call it idleFlag.
Next make a method that changes the animation to fight mode. This change would be by removing the idle animation and replacing it with the fight animation. This method also set's idleFlag to NO. Let's call the method "beginFightAnim"
And last, in your repeatActionForEver idle animation, right after your animateWithTextures animation, add a runBlock animation. In this block define a static variable (one that will be remembered in the calling of the block over and over) and increment it by +1, add an "if statement" that looks something like this -> if (my_static_var == number_of_frames_in_texture_animations && idleFlag). And in the "if statement" set the static variable to 0 and call "beginFightAnim"
After this all you have to do to change the animation is set idleFlag to YES.
Hope it works!
If you have any problems, please comment below.
I want to do a series of examples to make it easier to understand the matter. Suppose you have your node called playerAnimation, a typical atlasc with a plist where you have
player-idle1.png
player-idle2.png
player-idle3.png
...
If you want to intercept in real-time your animation to know what frame is running in that moment you can do:
override func update(currentTime: CFTimeInterval) {
if String(playerAnimation.texture).rangeOfString("player-idle") != nil {
print(String(playerAnimation.texture))
}
}
At this point, after you have assigned a "key" to your action (withKey:"idleAnimation") you could stop your specific idle action when you preefer to start the other next animation.
Another good thing is to build a structure to know everytime your player status and modify this variable each time you launch a new action or animation:
enum PlayerStatus: Int {
case Idle = 1
case Fight = 2
case Run = 3
case Jump = 4
case Die = 5
...
}
var currentStatus: PlayerStatus!