Search in sources :

Example 1 with PacketGenomeTrackerSync

use of forestry.core.network.packets.PacketGenomeTrackerSync in project ForestryMC by ForestryMC.

the class BreedingTracker method synchToPlayer.

@Override
public void synchToPlayer(EntityPlayer player) {
    if (player instanceof EntityPlayerMP && !(player instanceof FakePlayer)) {
        IBreedingTracker breedingTracker = getBreedingTracker(player);
        String modeName = breedingTracker.getModeName();
        setModeName(modeName);
        NBTTagCompound nbttagcompound = new NBTTagCompound();
        encodeToNBT(nbttagcompound);
        PacketGenomeTrackerSync packet = new PacketGenomeTrackerSync(nbttagcompound);
        NetworkUtil.sendToPlayer(packet, player);
    }
}
Also used : IBreedingTracker(forestry.api.genetics.IBreedingTracker) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) PacketGenomeTrackerSync(forestry.core.network.packets.PacketGenomeTrackerSync) FakePlayer(net.minecraftforge.common.util.FakePlayer)

Example 2 with PacketGenomeTrackerSync

use of forestry.core.network.packets.PacketGenomeTrackerSync in project ForestryMC by ForestryMC.

the class BreedingTracker method syncToPlayer.

private void syncToPlayer(Collection<String> discoveredSpecies, Collection<String> discoveredMutations, Collection<String> researchedMutations) {
    if (world != null && username != null && username.getName() != null) {
        EntityPlayer player = world.getPlayerEntityByName(username.getName());
        if (player instanceof EntityPlayerMP && !(player instanceof FakePlayer)) {
            IBreedingTracker breedingTracker = getBreedingTracker(player);
            String modeName = breedingTracker.getModeName();
            setModeName(modeName);
            NBTTagCompound nbtTagCompound = new NBTTagCompound();
            writeToNBT(nbtTagCompound, discoveredSpecies, discoveredMutations, researchedMutations);
            PacketGenomeTrackerSync packet = new PacketGenomeTrackerSync(nbtTagCompound);
            NetworkUtil.sendToPlayer(packet, player);
            for (String species : discoveredSpecies) {
                SpeciesDiscoveredTrigger.INSTANCE.trigger((EntityPlayerMP) player, AlleleManager.alleleRegistry.getAllele(species));
            }
        }
    }
}
Also used : IBreedingTracker(forestry.api.genetics.IBreedingTracker) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) PacketGenomeTrackerSync(forestry.core.network.packets.PacketGenomeTrackerSync) FakePlayer(net.minecraftforge.common.util.FakePlayer)

Aggregations

IBreedingTracker (forestry.api.genetics.IBreedingTracker)2 PacketGenomeTrackerSync (forestry.core.network.packets.PacketGenomeTrackerSync)2 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)2 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 FakePlayer (net.minecraftforge.common.util.FakePlayer)2 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1