-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Define default EntityFlag.BREATHING true (#25)
* Add experience attribute * init hungerManager and experienceManager to function initEntity() * Define default EntityFlag.BREATHING true
- Loading branch information
1 parent
4f9b9f4
commit 554e7af
Showing
3 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package org.sculk.entity.data; | ||
|
||
|
||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataMap; | ||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag; | ||
import org.cloudburstmc.protocol.bedrock.packet.SetEntityDataPacket; | ||
import org.sculk.Player; | ||
|
||
import java.util.EnumSet; | ||
|
||
/* | ||
* ____ _ _ | ||
* / ___| ___ _ _| | | __ | ||
* \___ \ / __| | | | | |/ / | ||
* ___) | (__| |_| | | < | ||
* |____/ \___|\__,_|_|_|\_\ | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* @author: SculkTeams | ||
* @link: http://www.sculkmp.org/ | ||
*/ | ||
public class SyncedEntityData { | ||
|
||
private final EnumSet<EntityFlag> flags = EnumSet.noneOf(EntityFlag.class); | ||
private final EntityDataMap entityDataMap = new EntityDataMap(); | ||
|
||
private final Player player; | ||
|
||
public SyncedEntityData(Player player) { | ||
this.player = player; | ||
} | ||
|
||
public void updateFlag() { | ||
SetEntityDataPacket setEntityDataPacket = new SetEntityDataPacket(); | ||
setEntityDataPacket.getMetadata().putFlags(this.flags); | ||
this.player.sendDataPacket(setEntityDataPacket); | ||
} | ||
|
||
public boolean getFlag(EntityFlag entityFlag) { | ||
return flags.contains(entityFlag); | ||
} | ||
|
||
public void setFlags(EntityFlag flags, boolean value) { | ||
if(this.flags.contains(flags) != value) { | ||
if(value) { | ||
this.flags.add(flags); | ||
} else { | ||
this.flags.remove(flags); | ||
} | ||
this.entityDataMap.putFlags(this.flags); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters