use of de.budschie.bmorph.morph.MorphItem in project BudschieMorphMod by Budschie.
the class MorphChangedSynchronizer method decode.
@Override
public MorphChangedPacket decode(PacketBuffer buffer) {
UUID playerUUID = buffer.readUniqueId();
boolean hasIndex = buffer.readBoolean(), hasItem = buffer.readBoolean();
Optional<Integer> morphIndex = Optional.empty();
Optional<MorphItem> morphItem = Optional.empty();
if (hasIndex)
morphIndex = Optional.of(buffer.readInt());
if (hasItem)
morphItem = Optional.of(MorphHandler.deserializeMorphItem(buffer.readCompoundTag()));
int amountOfAbilities = buffer.readInt();
ArrayList<String> abilities = new ArrayList<>(amountOfAbilities);
for (int i = 0; i < amountOfAbilities; i++) abilities.add(buffer.readString());
return new MorphChangedPacket(playerUUID, morphIndex, morphItem, abilities);
}
use of de.budschie.bmorph.morph.MorphItem in project BudschieMorphMod by Budschie.
the class RenderHandler method onRenderedHandler.
@SubscribeEvent(priority = EventPriority.HIGH)
public static void onRenderedHandler(RenderPlayerEvent.Pre event) {
LazyOptional<IMorphCapability> morph = event.getPlayer().getCapability(MorphCapabilityAttacher.MORPH_CAP);
if (morph.isPresent()) {
Optional<MorphItem> currentMorph = morph.resolve().get().getCurrentMorph();
if (currentMorph.isPresent()) {
event.setCanceled(true);
PlayerEntity player = event.getPlayer();
Entity toRender = cachedEntities.get(player.getUniqueID());
renderMorph(player, toRender, event.getMatrixStack(), event.getPartialRenderTick(), event.getBuffers(), event.getLight());
}
}
}
Aggregations