use of org.spongepowered.common.bridge.server.network.ServerGamePacketListenerImplBridge in project SpongeCommon by SpongePowered.
the class ResourcePackState method unwind.
@Override
public void unwind(BasicPacketContext phaseContext) {
final net.minecraft.server.level.ServerPlayer player = phaseContext.getPacketPlayer();
final ServerGamePacketListenerImpl connection = player.connection;
final ServerGamePacketListenerImplBridge mixinHandler = (ServerGamePacketListenerImplBridge) connection;
final ServerboundResourcePackPacketAccessor resource = phaseContext.getPacket();
final ResourcePackStatusEvent.ResourcePackStatus status;
ResourcePack pack;
switch(resource.accessor$action()) {
case ACCEPTED:
pack = mixinHandler.bridge$popReceivedResourcePack(true);
status = ResourcePackStatusEvent.ResourcePackStatus.ACCEPTED;
break;
case DECLINED:
pack = mixinHandler.bridge$popReceivedResourcePack(false);
status = ResourcePackStatusEvent.ResourcePackStatus.DECLINED;
break;
case SUCCESSFULLY_LOADED:
pack = mixinHandler.bridge$popAcceptedResourcePack();
status = ResourcePackStatusEvent.ResourcePackStatus.SUCCESSFULLY_LOADED;
break;
case FAILED_DOWNLOAD:
pack = mixinHandler.bridge$popAcceptedResourcePack();
status = ResourcePackStatusEvent.ResourcePackStatus.FAILED;
break;
default:
throw new AssertionError();
}
if (pack == null) {
return;
}
SpongeCommon.post(SpongeEventFactory.createResourcePackStatusEvent(PhaseTracker.getCauseStackManager().currentCause(), pack, (ServerPlayer) player, status));
}
Aggregations