use of net.minecraft.network.play.client.CPacketResourcePackStatus in project SpongeCommon by SpongePowered.
the class ResourcePackState method unwind.
@Override
public void unwind(BasicPacketContext phaseContext) {
final EntityPlayerMP player = phaseContext.getPacketPlayer();
final NetHandlerPlayServer connection = player.connection;
final IMixinNetHandlerPlayServer mixinHandler = (IMixinNetHandlerPlayServer) connection;
final CPacketResourcePackStatus resource = phaseContext.getPacket();
final ResourcePackStatusEvent.ResourcePackStatus status;
ResourcePack pack;
switch(resource.action) {
case ACCEPTED:
pack = mixinHandler.popReceivedResourcePack(true);
status = ResourcePackStatusEvent.ResourcePackStatus.ACCEPTED;
break;
case DECLINED:
pack = mixinHandler.popReceivedResourcePack(false);
status = ResourcePackStatusEvent.ResourcePackStatus.DECLINED;
break;
case SUCCESSFULLY_LOADED:
pack = mixinHandler.popAcceptedResourcePack();
status = ResourcePackStatusEvent.ResourcePackStatus.SUCCESSFULLY_LOADED;
break;
case FAILED_DOWNLOAD:
pack = mixinHandler.popAcceptedResourcePack();
status = ResourcePackStatusEvent.ResourcePackStatus.FAILED;
break;
default:
throw new AssertionError();
}
if (pack == null) {
return;
}
SpongeImpl.postEvent(SpongeEventFactory.createResourcePackStatusEvent(Sponge.getCauseStackManager().getCurrentCause(), pack, (Player) player, status));
}
Aggregations