de.teamlapen.lib.lib.network.ISyncable.loadUpdateFromNBT() - java examples

Here are the examples of the java api de.teamlapen.lib.lib.network.ISyncable.loadUpdateFromNBT() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1 Examples 7

16 View Complete Implementation : ClientProxy.java
Copyright GNU Lesser General Public License v3.0
Author : TeamLapen
@Override
public void handleUpdateEnreplacedyPacket(UpdateEnreplacedyPacket msg) {
    PlayerEnreplacedy player = Minecraft.getInstance().player;
    if (player == null) {
        LOGGER.error("Cannot handle update package because sending player enreplacedy is null. Message: {}", msg);
    } else {
        Enreplacedy e = player.getEnreplacedyWorld().getEnreplacedyByID(msg.getId());
        if (e == null) {
            LOGGER.error("Did not find enreplacedy {}", msg.getId());
            if (msg.isPlayerItself()) {
                LOGGER.error("Message is meant for player itself, but id mismatch {} {}. Loading anyway.", player.getEnreplacedyId(), msg.getId());
                e = player;
            }
        }
        if (e != null) {
            if (msg.getData() != null) {
                ISyncable syncable;
                try {
                    syncable = (ISyncable) e;
                    syncable.loadUpdateFromNBT(msg.getData());
                } catch (ClreplacedCastException ex) {
                    LOGGER.warn("Target enreplacedy {} does not implement ISyncable ({})", e, ex);
                }
            }
            if (msg.getCaps() != null) {
                for (String key : msg.getCaps().keySet()) {
                    handleCapability(e, new ResourceLocation(key), msg.getCaps().getCompound(key));
                }
            }
        }
    }
}