Search in sources :

Example 6 with MorphItem

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);
}
Also used : MorphItem(de.budschie.bmorph.morph.MorphItem) ArrayList(java.util.ArrayList) UUID(java.util.UUID) MorphChangedPacket(de.budschie.bmorph.network.MorphChangedSynchronizer.MorphChangedPacket)

Example 7 with MorphItem

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());
        }
    }
}
Also used : IMorphCapability(de.budschie.bmorph.capabilities.IMorphCapability) AbstractSkeletonEntity(net.minecraft.entity.monster.AbstractSkeletonEntity) AdvancedAbstractClientPlayerEntity(de.budschie.bmorph.morph.player.AdvancedAbstractClientPlayerEntity) MobEntity(net.minecraft.entity.MobEntity) AbstractClientPlayerEntity(net.minecraft.client.entity.player.AbstractClientPlayerEntity) Entity(net.minecraft.entity.Entity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) MorphItem(de.budschie.bmorph.morph.MorphItem) AdvancedAbstractClientPlayerEntity(de.budschie.bmorph.morph.player.AdvancedAbstractClientPlayerEntity) AbstractClientPlayerEntity(net.minecraft.client.entity.player.AbstractClientPlayerEntity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Aggregations

MorphItem (de.budschie.bmorph.morph.MorphItem)7 IMorphCapability (de.budschie.bmorph.capabilities.IMorphCapability)5 ArrayList (java.util.ArrayList)3 UUID (java.util.UUID)3 PlayerEntity (net.minecraft.entity.player.PlayerEntity)3 ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)3 SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)3 MorphEntity (de.budschie.bmorph.entity.MorphEntity)2 FavouriteList (de.budschie.bmorph.morph.FavouriteList)1 MorphList (de.budschie.bmorph.morph.MorphList)1 AdvancedAbstractClientPlayerEntity (de.budschie.bmorph.morph.player.AdvancedAbstractClientPlayerEntity)1 MorphPacket (de.budschie.bmorph.network.MorphCapabilityFullSynchronizer.MorphPacket)1 MorphChangedPacket (de.budschie.bmorph.network.MorphChangedSynchronizer.MorphChangedPacket)1 Pair (de.budschie.bmorph.util.Pair)1 HashMap (java.util.HashMap)1 AbstractClientPlayerEntity (net.minecraft.client.entity.player.AbstractClientPlayerEntity)1 Entity (net.minecraft.entity.Entity)1 EntityType (net.minecraft.entity.EntityType)1 MobEntity (net.minecraft.entity.MobEntity)1 AbstractSkeletonEntity (net.minecraft.entity.monster.AbstractSkeletonEntity)1