Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Redstone] Updates from master branch #1419

Merged
merged 3 commits into from
May 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/main/java/cn/nukkit/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import cn.nukkit.event.player.PlayerAsyncPreLoginEvent.LoginResult;
import cn.nukkit.event.player.PlayerInteractEvent.Action;
import cn.nukkit.event.player.PlayerTeleportEvent.TeleportCause;
import cn.nukkit.event.player.PlayerJumpEvent;
import cn.nukkit.event.server.DataPacketReceiveEvent;
import cn.nukkit.event.server.DataPacketSendEvent;
import cn.nukkit.form.window.FormWindow;
Expand Down Expand Up @@ -2485,6 +2486,8 @@ public void onCompletion(Server server) {
this.respawn();
break;
case PlayerActionPacket.ACTION_JUMP:
PlayerJumpEvent playerJumpEvent = new PlayerJumpEvent(this);
this.server.getPluginManager().callEvent(playerJumpEvent);
break packetswitch;
case PlayerActionPacket.ACTION_START_SPRINT:
PlayerToggleSprintEvent playerToggleSprintEvent = new PlayerToggleSprintEvent(this, true);
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/cn/nukkit/block/BlockSugarcane.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,12 @@ public int onUpdate(int type) {
for (int y = 1; y < 3; ++y) {
Block b = this.getLevel().getBlock(new Vector3(this.x, this.y + y, this.z));
if (b.getId() == AIR) {
this.getLevel().setBlock(b, Block.get(BlockID.SUGARCANE_BLOCK), false);
BlockGrowEvent ev = new BlockGrowEvent(b, Block.get(BlockID.SUGARCANE_BLOCK));
Server.getInstance().getPluginManager().callEvent(ev);

if (!ev.isCancelled()) {
this.getLevel().setBlock(b, Block.get(BlockID.SUGARCANE_BLOCK), false);
}
break;
}
}
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/cn/nukkit/event/player/PlayerJumpEvent.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package cn.nukkit.event.player;

import cn.nukkit.Player;
import cn.nukkit.event.HandlerList;

public class PlayerJumpEvent extends PlayerEvent {
private static final HandlerList handlers = new HandlerList();

public static HandlerList getHandlers() {
return handlers;
}

public PlayerJumpEvent(Player player){
this.player = player;
}
}
1 change: 1 addition & 0 deletions src/main/java/cn/nukkit/level/Level.java
Original file line number Diff line number Diff line change
Expand Up @@ -3236,6 +3236,7 @@ public void addEntityMovement(Entity entity, double x, double y, double z, doubl
pk.yaw = (float) yaw;
pk.headYaw = (float) headYaw;
pk.pitch = (float) pitch;
pk.onGround = entity.onGround;

Server.broadcastPacket(entity.getViewers().values(), pk);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ public void encode() {
this.reset();
this.putEntityRuntimeId(this.eid);
byte flags = 0;
if (teleport) {
if (onGround) {
flags |= 0x01;
}
if (onGround) {
if (teleport) {
flags |= 0x02;
}
this.putByte(flags);
Expand Down