-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
95d3440
commit d68705d
Showing
23 changed files
with
371 additions
and
135 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
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
7 changes: 3 additions & 4 deletions
7
src/main/java/xiamomc/morph/backends/server/renderer/network/datawatcher/ValueIndex.java
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
51 changes: 51 additions & 0 deletions
51
src/main/java/xiamomc/morph/backends/server/renderer/network/datawatcher/WatcherIndex.java
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,51 @@ | ||
package xiamomc.morph.backends.server.renderer.network.datawatcher; | ||
|
||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; | ||
import org.bukkit.entity.EntityType; | ||
import org.bukkit.entity.Player; | ||
import xiamomc.morph.backends.server.renderer.network.datawatcher.values.ArmorStandValues; | ||
import xiamomc.morph.backends.server.renderer.network.datawatcher.watchers.SingleWatcher; | ||
import xiamomc.morph.backends.server.renderer.network.datawatcher.watchers.types.AllayWatcher; | ||
import xiamomc.morph.backends.server.renderer.network.datawatcher.watchers.types.ArmorStandWatcher; | ||
import xiamomc.morph.backends.server.renderer.network.datawatcher.watchers.types.LivingEntityWatcher; | ||
import xiamomc.morph.backends.server.renderer.network.datawatcher.watchers.types.PlayerWatcher; | ||
|
||
import java.util.Map; | ||
import java.util.function.Function; | ||
|
||
public class WatcherIndex | ||
{ | ||
public static WatcherIndex getInstance() | ||
{ | ||
if (instance == null) instance = new WatcherIndex(); | ||
return instance; | ||
} | ||
|
||
private static WatcherIndex instance; | ||
|
||
public WatcherIndex() | ||
{ | ||
instance = this; | ||
|
||
setTypeWatcher(EntityType.PLAYER, PlayerWatcher::new); | ||
setTypeWatcher(EntityType.ALLAY, AllayWatcher::new); | ||
setTypeWatcher(EntityType.ARMOR_STAND, ArmorStandWatcher::new); | ||
} | ||
|
||
private void setTypeWatcher(EntityType type, Function<Player, SingleWatcher> func) | ||
{ | ||
typeWatcherMap.put(type, func); | ||
} | ||
|
||
private final Map<EntityType, Function<Player, SingleWatcher>> typeWatcherMap = new Object2ObjectOpenHashMap<>(); | ||
|
||
public SingleWatcher getWatcherForType(Player bindingPlayer, EntityType entityType) | ||
{ | ||
var watcherFunc = typeWatcherMap.getOrDefault(entityType, null); | ||
|
||
if (watcherFunc == null) | ||
return new LivingEntityWatcher(bindingPlayer, entityType); | ||
|
||
return watcherFunc.apply(bindingPlayer); | ||
} | ||
} |
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
14 changes: 14 additions & 0 deletions
14
...n/java/xiamomc/morph/backends/server/renderer/network/datawatcher/values/AllayValues.java
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,14 @@ | ||
package xiamomc.morph.backends.server.renderer.network.datawatcher.values; | ||
|
||
public class AllayValues extends MobValues | ||
{ | ||
public final SingleValue<Boolean> DANCING = getSingle(false); | ||
public final SingleValue<Boolean> CAN_DUPLICATE = getSingle(false); | ||
|
||
public AllayValues() | ||
{ | ||
super(); | ||
|
||
this.registerSingle(DANCING); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...a/xiamomc/morph/backends/server/renderer/network/datawatcher/values/ArmorStandValues.java
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,24 @@ | ||
package xiamomc.morph.backends.server.renderer.network.datawatcher.values; | ||
|
||
import net.minecraft.core.Rotations; | ||
|
||
public class ArmorStandValues extends LivingEntityValues | ||
{ | ||
public final SingleValue<Byte> DATA_FLAGS = getSingle((byte)0); | ||
public final SingleValue<Rotations> HEAD_ROTATION = getSingle(new Rotations(0, 0, 0)); | ||
public final SingleValue<Rotations> BODY_ROTATION = getSingle(new Rotations(0, 0, 0)); | ||
public final SingleValue<Rotations> LEFT_ARM_ROTATION = getSingle(new Rotations(-10, 0, -10)); | ||
public final SingleValue<Rotations> RIGHT_ARM_ROTATION = getSingle(new Rotations(-15, 0, 10)); | ||
public final SingleValue<Rotations> LEFT_LEG_ROTATION = getSingle(new Rotations(-1, 0, -1)); | ||
public final SingleValue<Rotations> RIGHT_LEG_ROTATION = getSingle(new Rotations(1, 0, 1)); | ||
|
||
public ArmorStandValues() | ||
{ | ||
super(); | ||
|
||
registerSingle(DATA_FLAGS, | ||
HEAD_ROTATION, BODY_ROTATION, | ||
LEFT_ARM_ROTATION, RIGHT_ARM_ROTATION, | ||
LEFT_LEG_ROTATION, RIGHT_LEG_ROTATION); | ||
} | ||
} |
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
19 changes: 9 additions & 10 deletions
19
...xiamomc/morph/backends/server/renderer/network/datawatcher/values/LivingEntityValues.java
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 |
---|---|---|
@@ -1,24 +1,23 @@ | ||
package xiamomc.morph.backends.server.renderer.network.datawatcher.values; | ||
|
||
import net.minecraft.core.BlockPos; | ||
import org.bukkit.Location; | ||
|
||
import java.util.Optional; | ||
|
||
public class LivingEntityValues extends AbstractValues | ||
public class LivingEntityValues extends EntityValues | ||
{ | ||
public final SingleValue<Byte> LIVING_FLAGS = SingleValue.of(8, (byte)0); | ||
public final SingleValue<Float> HEALTH = SingleValue.of(9, 1f); | ||
public final SingleValue<Integer> POTION_COLOR = SingleValue.of(10, 0); | ||
public final SingleValue<Boolean> POTION_ISAMBIENT = SingleValue.of(11, false); | ||
public final SingleValue<Integer> STUCKED_ARROWS = SingleValue.of(12, 0); | ||
public final SingleValue<Integer> BEE_STINGERS = SingleValue.of(13, 0); | ||
public final SingleValue<Optional<BlockPos>> BED_POS = SingleValue.of(14, Optional.of(new BlockPos(0,0,0))); | ||
public final SingleValue<Byte> LIVING_FLAGS = getSingle((byte)0); | ||
public final SingleValue<Float> HEALTH = getSingle(1f); | ||
public final SingleValue<Integer> POTION_COLOR = getSingle(0); | ||
public final SingleValue<Boolean> POTION_ISAMBIENT = getSingle(false); | ||
public final SingleValue<Integer> STUCKED_ARROWS = getSingle(0); | ||
public final SingleValue<Integer> BEE_STINGERS = getSingle(0); | ||
public final SingleValue<Optional<BlockPos>> BED_POS = getSingle(Optional.of(new BlockPos(0,0,0))); | ||
|
||
public LivingEntityValues() | ||
{ | ||
super(); | ||
|
||
registerValue(LIVING_FLAGS, HEALTH, POTION_COLOR, POTION_ISAMBIENT, STUCKED_ARROWS, BED_POS, BEE_STINGERS); | ||
registerSingle(LIVING_FLAGS, HEALTH, POTION_COLOR, POTION_ISAMBIENT, STUCKED_ARROWS, BED_POS, BEE_STINGERS); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...ain/java/xiamomc/morph/backends/server/renderer/network/datawatcher/values/MobValues.java
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,13 @@ | ||
package xiamomc.morph.backends.server.renderer.network.datawatcher.values; | ||
|
||
public class MobValues extends LivingEntityValues | ||
{ | ||
public final SingleValue MOB_FLAGS = getSingle((byte)0); | ||
|
||
public MobValues() | ||
{ | ||
super(); | ||
|
||
this.registerSingle(MOB_FLAGS); | ||
} | ||
} |
14 changes: 8 additions & 6 deletions
14
.../java/xiamomc/morph/backends/server/renderer/network/datawatcher/values/PlayerValues.java
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 |
---|---|---|
@@ -1,16 +1,18 @@ | ||
package xiamomc.morph.backends.server.renderer.network.datawatcher.values; | ||
|
||
public class PlayerValues extends AbstractValues | ||
public class PlayerValues extends LivingEntityValues | ||
{ | ||
public final SingleValue<Float> ABSORPTION_AMOUNT = SingleValue.of(15, 0f); | ||
public final SingleValue<Integer> SCORE = SingleValue.of(16, 0); | ||
public final SingleValue<Byte> SKIN = SingleValue.of(17, (byte)127); | ||
public final SingleValue<Byte> MAINHAND = SingleValue.of(18, (byte)1); | ||
public final SingleValue<Float> ABSORPTION_AMOUNT = getSingle(0f); | ||
public final SingleValue<Integer> SCORE = getSingle(0); | ||
public final SingleValue<Byte> SKIN = getSingle((byte)0); //127 | ||
public final SingleValue<Byte> MAINHAND = getSingle((byte)1); | ||
|
||
public PlayerValues() | ||
{ | ||
super(); | ||
|
||
registerValue(ABSORPTION_AMOUNT, SCORE, SKIN, MAINHAND); | ||
System.out.println("SKIN is on index " + SKIN.index()); | ||
|
||
registerSingle(ABSORPTION_AMOUNT, SCORE, SKIN, MAINHAND); | ||
} | ||
} |
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
17 changes: 0 additions & 17 deletions
17
...in/java/xiamomc/morph/backends/server/renderer/network/datawatcher/watchers/Watchers.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.